should the orelse
operator be right-associative?
#15108
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
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: