-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Type inference failure in unreachable code #40073
Comments
Maybe I should paste the error message too:
|
Note that X::B is an unreachable expression. |
That observation may be the key to it, thanks. I hadn't realised my In this case the error makes perfect sense (since Simpler version: play Thinking about it some more, I realise there's a reason unreachable code is usually reported as a warning and not an error (outside the Java world!): because a smarter compiler could make previously "valid" code no longer compile. So that leaves three approaches:
Going back to my original use-case, I later added other arms to that match block which didn't all return, and did use the code below it (crazy as it sounds, I was trying to diagnose this error while doing a rebase). In this case, approach (1) would have helped me solve the problem sooner, but meant I'd have had to change the code again later. Approach (3) may have been okay or may have let me commit erroneous code initially, and only report issues when adding other |
The following code works on stable 1.15.1 but not on current nightly compilers (Play editor):
I encountered this using
Result
but realised a templated enum is sufficient. I can't replicate when replacing thematch
with anif
.The text was updated successfully, but these errors were encountered: