Fix scoping and break statements.
Variables declared in the loop were not properly disposed of when you broke out of the loop.
This commit is contained in:
@@ -2,7 +2,6 @@ var list = []
|
||||
|
||||
for (i in [1, 2, 3]) {
|
||||
list.add(fn IO.print(i))
|
||||
//list.add(fn IO.print(i))
|
||||
}
|
||||
|
||||
for (f in list) f.call
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
var f = fn {
|
||||
for (i in [1, 2, 3]) {
|
||||
return fn IO.print(i)
|
||||
}
|
||||
}
|
||||
|
||||
var g = f.call
|
||||
g.call
|
||||
// expect: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
var f = fn {
|
||||
for (i in [1, 2, 3]) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
IO.print(f.call)
|
||||
// expect: 1
|
||||
@@ -18,3 +18,6 @@ for
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
|
||||
// TODO: Return from inside for loop.
|
||||
// TODO: Return closure from inside for loop.
|
||||
Reference in New Issue
Block a user