-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern matching on Booleans doesn't check exhaustiveness #3111
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3111?orig=1 |
@paulp said: |
@lrytz said: |
@axel22 said: |
@axel22 said: |
@paulp said: |
@retronym said: Welcome to Scala version 2.10.0-20120524-094715-123050cf07 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val b: Boolean = false
b: Boolean = false
scala> b match { case false => true }
<console>:9: warning: match may not be exhaustive.
It would fail on the following input: true
b match { case false => true }
^
res0: Boolean = true
scala> b match { case true => true; case false => false; case _ => true }
res1: Boolean = false |
@retronym said: |
Consider the following:
Expectation: I'd hope for a non-exhaustive match warning.
Actual result: run-time MatchError
Likewise for:
Expectation: I would expect to receive an unreachable code error.
Actual: Silent, happy, deluded compiler.
Tested on 2.8.0 nightly as of Feb 26, 2010.
The text was updated successfully, but these errors were encountered: