It looks like the preprocessor expansion of the arithmetic assignment operators breaks a traditional expectation of precedence:
x += true and 1 or 2 |
expands to:
x = x + true and 1 or 2 -- runtime error: attempt to perform arithmetic on a boolean value |
where "x + true" binds more tightly than "true and ...". The fix is to use parens in the expansion:
x = x + (true and 1 or 2) |
The workaround is to use parens around the original rhs.
P#48604 2018-01-27 18:27 ( Edited 2018-01-28 06:39)
[Please log in to post a comment]