You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to Scala 3.1.0-RC1-bin-20210818-868906d-NIGHTLY-git-868906d
scala> class C {
| def m(x: true) = x match {
| case true => println("the one true path")
| }
| }
|
// defined class C
-- Warning:
2 | def m(x: true) = x match {
| ^
| match may not be exhaustive.
|
| It would fail on pattern case: false
The warning is spurious; x has a singleton type that isn't taken into account.
This is a regression from Scala 2, where the corresponding bug is scala/bug#11603 and was fixed for Scala 2.13.4 by scala/scala#9209
The text was updated successfully, but these errors were encountered:
scala>defm(x: true) = x match { casetrue=>1 }
1|defm(x: true) = x match { casetrue=>1 }
|^|match may not be exhaustive.
||It would fail on pattern case:falsedefm(x: true):Int
scala>defm(x: true) = x match { casetrue=>1casefalse=>2 }
defm(x: true):Int
It's not emitting a reachability warning on the case false.
SethTisue
changed the title
Scrutinee type in pattern matches is widened, impairing exhaustivity (and reachability?) analysis
Scrutinee type in pattern matches is widened, impairing exhaustivity and reachability analysis
Aug 20, 2021
The warning is spurious;
x
has a singleton type that isn't taken into account.This is a regression from Scala 2, where the corresponding bug is scala/bug#11603 and was fixed for Scala 2.13.4 by scala/scala#9209
The text was updated successfully, but these errors were encountered: