summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-02-08 23:36:30 +0100
committerJo-Philipp Wich <jo@mein.io>2022-02-08 23:37:03 +0100
commita317c17f5ddfc3f749d349de01eeea5cad3eb162 (patch)
tree3680e245749106df8b1b50324fc1ebebe33d7d32 /tests
parent78cdd2691a24dcb62f8342eabecfa8eeb2f301c2 (diff)
compiler: fix incorrect loop break targets
When patching jump targets for break statments while compiling for-loop statments, we need jump beyond the instructions popping intermediate loop variables off the stack but before the pop instructions removing local loop body variables to prevent a stack position mismatch between compiler and vm. Before that change, local loop body variables remained on the stack, breaking the expected stack layout. Fixes: b3d758b compiler: ("fix for/break miscompilation") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/custom/04_bugs/10_break_stack_mismatch12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/custom/04_bugs/10_break_stack_mismatch b/tests/custom/04_bugs/10_break_stack_mismatch
index ae16dac..c9c82c5 100644
--- a/tests/custom/04_bugs/10_break_stack_mismatch
+++ b/tests/custom/04_bugs/10_break_stack_mismatch
@@ -13,12 +13,14 @@ values or segmentation faults at runtime.
for (let y in [2])
break;
- print(x, "\n");
+ let z = 3;
+
+ print([ x, z ], "\n");
%}
-- End --
-- Expect stdout --
-1
+[ 1, 3 ]
-- End --
@@ -29,10 +31,12 @@ values or segmentation faults at runtime.
for (let y = 0; y < 1; y++)
break;
- print(x, "\n");
+ let z = 3;
+
+ print([ x, z ], "\n");
%}
-- End --
-- Expect stdout --
-1
+[ 1, 3 ]
-- End --