-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
should the orelse
operator be right-associative?
#15108
Comments
Note: possible interaction with the accepted proposal at #114 (comment) in which associativity is a factor (and which was written before |
I don't get how associativity plays into this... |
|
Current plan is to resolve by requiring parens. |
Consider the following code:
As of zig
0.11.0-dev.2298+5d63d1115
, this fails to compile with the following error message:This error message indicates that the line is being parsed in a left-associative fashion, i.e.
In my opinion, the more intuitive behavior would be for
orelse
to be right-associative, i.e.If this wasn't an explicit design choice, I think it makes sense to change it. Right-associativity would make
orelse
behave like a short-circuiting boolean operator, which I think is logical behavior given its naming and functionality. For directly applicable prior-art, both C#'s and Swift's null-coalescing operators are right-associative.The text was updated successfully, but these errors were encountered: