Zig Version
0.13.0
Steps to Reproduce and Observed Output
In the following code, I incorrectly used || instead of or (likely a common beginner mistake).
fn example(x: i32, y: i32) bool {
return
x < y
|| x > y + 10
|| y - x == 5;
}
The compiler gives an error about chaining comparison operators, likely because || has a higher precedence than comparison operators.
main.zig:12:24: error: comparison operators cannot be chained
|| pos.col < 0
^
Expected Output
Instead, it would be much more helpful to give an error suggesting the or keyword instead of the || operator. This could be detected by using the fact that || is not defined for anything except for the Error Set Type, meaning that even without the comparison operators, it would not be allowed to compile.
Zig Version
0.13.0
Steps to Reproduce and Observed Output
In the following code, I incorrectly used
||instead ofor(likely a common beginner mistake).The compiler gives an error about chaining comparison operators, likely because
||has a higher precedence than comparison operators.Expected Output
Instead, it would be much more helpful to give an error suggesting the
orkeyword instead of the||operator. This could be detected by using the fact that||is not defined for anything except for the Error Set Type, meaning that even without the comparison operators, it would not be allowed to compile.