-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
continue
and break
should not be allowed on RHS of expression
#50415
Comments
continue
should not be allowed on RHS of expressioncontinue
and break
should not be allowed on RHS of expression
Then probably |
The title should probably read "assignment", not "expression"; those don't have a RHS, they're a block of expressions/literals. I'm using the (non-performance critical) |
Isn't that identical to But upon seeing that, I vaguely remember there might be an issue already about using |
Yes, seeing non-booleans as arguments to control flow feels very odd though :) If we disallow that, I don't think the common pattern
will continue to work either. |
Isn't BTW, I'm not at all convinced we should disallow any of this in the parser. Might better be a job for a linter. |
Yes, but
Yes, agreed. |
the short circuiting operators kind of own their own terrain; I agree that constructions like what seems much more controversial to me, and what I believe should be a syntax error, is allowing
and of course the original example with in fact, I bet the following two rules would catch 99% of cases:
since
|
FYI, disallowing
because
(Note the Maybe it's worth changing |
Afaik the compiler normally allows unreachable code without complaint. So this feels more like a linter thing to me. |
the I don't think this is "just a linter" issue. more broadly it's pretty inconsistent when
legal but not when I wrap the where in braces, so this gives syntax error
|
this continues through the whole loop, but
x
remains undefined. I would expect a syntax error here. the behavior is similarly confusing in cases like thisThe text was updated successfully, but these errors were encountered: