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
Guard causes pattern matching to not warn of non-exhaustivity #7631
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7631?orig=1 |
@paulp said: Actually like a lot of things, the useful warning would be issued at the point when you change the code, not as a consequence of the code when considered in isolation. ("Warning: the guard you just added disabled exhaustiveness checking.") That of course is not something which can be done in the compiler given present abilities. |
Scott Danzig (sdanzig) said (edited on Jul 3, 2013 2:40:16 PM UTC): I agree that the currently impractical warning at the time of the change would be most helpful, but it'd easily be missed unless there was a separate log for "change-related notifications" along with the diff. |
@paulp said: The major category where I dream of being told that something changed is variable shadowing, e.g. when you change something called "sym" to another name, only to see a "sym" from an enclosing scope step in as a substitute, and everything compiles and you don't know that you failed to change a reference to "sym" to the new name. |
Scott Danzig (sdanzig) said: |
in Scala 2.10.2, this warns me about a non-exhaustive pattern match...
The compiler should be able to determine that a guard clause cannot increase exhaustivity. While I can accept the decision not to make the exhaustivity search be pessimistic (which could result in some false warnings, if something always evaluates to true for some reason), it should at least be able to determine that the case of TestB() is not handled.
The text was updated successfully, but these errors were encountered: