-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Compile error when a function branch always returns early #4565
Comments
I also found this interesting one while trying to reproduce it. If you try to run this code, it gives two errors: the type of |
Note that if a |
This match is exhaustive, no? |
Hmm, it should be. @jemc might know more. |
I believe that comes not from exhaustive but from "jumps away early" being treated as a None by the compiler as all expressions have to return something and error returns None. That None might never happen, but it's still a thing. |
Sean opened a new ticket for the "exhaustive match with The initial code shown in the ticket is still its own bug. |
Issue ticket #2792 (which reports two separate bugs) mentions this same bug for loops in the 2nd report. |
We discussed this in the sync call today. Here's a short summary. For functions where the return type signature is Separately, if there's code after a control block (like this if statement) which jumps away in every branch, we show a compiler error for the next expression after that block, if there is one. These two features combined, give us the error above, with the invisible To fix this, someone would need to update our Sean asked if we can instead avoid inserting the magic |
With this code, ponyc complains the first line of
maybe_error
isn't reachable. This modified version compiles as expected.Match seems to give a different error. This code incorrectly believes the function body is None.
Reproduced in ponyc versions 0.58.0 and 0.58.7.
The text was updated successfully, but these errors were encountered: