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
spurious unreachability with guarded default, and unpositioned warning #6048
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6048?orig=1 |
@adriaanm said: |
@paulp said: It is like, if every time you saw if (false && condition) { ... } You said "Warning! Block of code will never execute!" Well yeah, that's why I put "if (false)" in there, you don't need to hassle me about it scalac. I could go either way on this, but in the absence of someone identifying a plausible case where this is helpful, I'd say the type of the guard should be widened. |
@paulp said: |
@adriaanm said: |
@adriaanm said: |
@adriaanm said: def test1(x: Int) = x match {
case c if c < 0 => 0
case 1 => 1
case _ => 2
} |
@adriaanm said: |
In the following, both f1 and f2 receive incorrect unreachable warnings. In the second variation, the warning is completely unpositioned - it literally just emits "warning: unreachable code". Since the file I was compiling at the time had about a thousand pattern matches in it, I was reminded of the value of accurate positions.
The text was updated successfully, but these errors were encountered: