You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think %- (mod with negated RHS) with no space in between should be a parse error, since the user most likely intended -% and there is a chance (albeit small) that it can parse and run.
This came from a question posted on #zig-help on the Discord community:
error: negationoftype'u8'constnew=old%-amount;
The poster intended -% but the transposed %- parses as well, and instead the poster got an error about illegally negating amount.
I also managed to come up with a test that causes the unintuitive behaviour to parse and run:
It's surprisingly hard to hit this case, because if a and b were signed, you get an error about needing to use @rem or @mod instead. But here it passes through fine since both a and b are comptime_int.
The text was updated successfully, but these errors were encountered:
I think
%-
(mod with negated RHS) with no space in between should be a parse error, since the user most likely intended-%
and there is a chance (albeit small) that it can parse and run.This came from a question posted on #zig-help on the Discord community:
The poster intended
-%
but the transposed%-
parses as well, and instead the poster got an error about illegally negatingamount
.I also managed to come up with a test that causes the unintuitive behaviour to parse and run:
It's surprisingly hard to hit this case, because if
a
andb
were signed, you get an error about needing to use@rem
or@mod
instead. But here it passes through fine since botha
andb
arecomptime_int
.The text was updated successfully, but these errors were encountered: