Improve error message for statements used as expressions #105431
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The code below has superfluous semicolons in the branches of the if expression:
The error message that results is:
This can be confusing to beginners, who may not understand unit type. However, since the expressions
3
and4
can be shown to have no side effects, the code (as is) can't be what the user intended. Could the compiler produce a more targeted error message that mentions the superfluous semicolon?The text was updated successfully, but these errors were encountered: