-
Notifications
You must be signed in to change notification settings - Fork 219
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 check error on non-unit expression statements #2304
Comments
huh... |
Right, this is intended as it is similar to the unused variable warning where the compiler warns if a variable is never used. Here, it is the expression itself that is never used. Like the unused variable warning though, this should likely be a warning rather than an error.
Good catch, we should make sure this is consistent |
I'll submit a PR that handles the case where there's only one expression with semi. You're right we should probably convert it to a warning since it's a breaking change (there are tests failing if we handle that case and keep it an error). We could also print a nicer message while we're at it (e.g. |
Aim
Non-unit expression statements inside a Block fail to type check, if they're not the last statement in the block:
Note that this type checks properly:
This is particularly weird in the case of function calls, since if we call a function and ignore its return value we get a cryptic error:
Expected Behavior
No type errors on any of these examples
Bug
The reason is that we set the statement's type to the expression type which is non-unit:
... and later on we attempt to unify it to the unit type:
To Reproduce
No response
Installation Method
Compiled from source
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
Yes
Support Needs
No response
The text was updated successfully, but these errors were encountered: