bug icon indicating copy to clipboard operation
bug copied to clipboard

Missing exhaustivity warning on ints (and other switchable types)

Open nrinaudo opened this issue 4 years ago • 7 comments

reproduction steps

Scala 2.13.4 is supposed to implement the following:

Guards (case .. if .. =>) no longer disable the exhaustivity checker. Rather, the checker checks for exhaustivity using the "pessimistic" assumption that the guard may be false.

(Source)

Yet, the following code compiles without warning:

def test(i: Int) = i match {
  case value if value < 0 => true
  case value if value > 10 => false
}

This has been tried with and without the -Xlint:strict-unsealed-patmat scalac option.

problem

The way I understand the quoted sentence is: the compiler will consider both branches of the pattern match as potentially being false at the same time, which will cause it to emit a non-exhaustivity warning.

This is not what's happening.

nrinaudo avatar Nov 25 '20 14:11 nrinaudo