-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unreachable case warning could point to previous matching case #4660
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
Comments
If we actually run this code and set f to The reason we incorrectly, I think, get this warning here is that after we project the pattern That said, what would we want the "better warning message" to look like? If every case in a match is reachable, then if the last case matches only null it's because all the previous cases contributed to that. |
The test case comes from scala#4660, which is a related bug.
The test case comes from scala#4660, which is a related bug.
What's fixed is that now we get the correct warning, but it still doesn't explain the reasoning as asked in the OP, so this enhancement issue shouldn't be closed. But it already has all the correct labels. It might also not be hard to do better: The debugging messages already show the internal reasoning, they're just not designed for end users and can't be enabled without recompiling Dotty to change the relevant printer. |
I incline to close this with |
@Blaisorblade which debugging messages did you have in mind to add to the error message? |
@abeln replace |
I see. That feels like a change with larger implications, though. I'd agree with Fengyun that we either put on hold or close this, since we now have the correct error message that makes more sense. We could file a separate bug for "-Ylog". |
Created #4953 for |
Given:
We get the warning:
This is confusing since it doesn't explain why only
null
is matched. Here it's easy to see that this is because we matched onOne
previously and thatBla
is a subtype ofOne
, but in a long series of case this might be very hard to understand. A better warning message would explain all of this.The text was updated successfully, but these errors were encountered: