summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/99_bugs/45_compiler_loop_ctrl_unclosed_upvals
blob: d4b7ed8cde74cacb17bff85985663b5efe3ddb27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
When compiling loop control statements, the compiler incorrectly emitted an
I_POP instead of an I_CUPV instruction for open upvalues, causing closures to
reference unclosed upvalues that went out of scope, potentially leading to
invalid stack accesses in subsequent code.

-- Testcase --
{%
	let dest;

	for (let i in [ 1 ]) {
		let foo = i;
		dest = () => print(foo, '\n');
		continue;
	}

	dest();
%}
-- End --

-- Expect stdout --
1
-- End --