diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-11-14 22:10:12 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-11-15 01:21:32 +0100 |
commit | fdc9b6a3841d7346dab6f4aeea06322be0d3ee95 (patch) | |
tree | 39537641aa77efc0202d60fd270a592d4b660070 /tests | |
parent | 5fd5e8c3d785da27b90320f6ac93853ecf87eeae (diff) |
compiler: fix `??=`, `||=` and `&&=` logical assignment semantics
When compiling logical assignment expressions, ensure that the right hand
side of the assignment is not evaluated when the assignment condition is
unfulfilled.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/custom/00_syntax/25_and_or_assignment | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/custom/00_syntax/25_and_or_assignment b/tests/custom/00_syntax/25_and_or_assignment index 4dbc5f3..d6a9415 100644 --- a/tests/custom/00_syntax/25_and_or_assignment +++ b/tests/custom/00_syntax/25_and_or_assignment @@ -53,3 +53,33 @@ expression result if the lhs is falsy. printf("%.J\n", [ x, y, z ]); %} -- End -- + + +3. Ensure that the assignment value expression is not evaluated if the +assignment condition is false. + +-- Expect stdout -- +[ + 0, + 0, + 0 +] +-- End -- + +-- Testcase -- +{% + a = 0; + b = 0; + c = 0; + + x = false; + y = false; + z = true; + + x ??= a++; + y &&= b++; + z ||= c++; + + printf("%.J\n", [ a, b, c ]); +%} +-- End -- |