fix: properly dispose loop-scoped variables and exit scopes on break
Replace the single `loopBody` index with a `Loop` struct that tracks scope depth, enabling the compiler to emit correct scope-exit code when a `break` statement is encountered inside nested blocks. Also add `WREN_DUMP_COMPILED_CODE` debug flag and new test cases for closures capturing loop variables after break, return inside loops, and nested loop scoping.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
for (i in 0..10) {
|
||||
IO.print(i)
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
{
|
||||
var b = "b"
|
||||
{
|
||||
var c = "c"
|
||||
if (i > 1) break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// expect: 0
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
Reference in New Issue
Block a user