mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Fix crash bug in closure capturing.
This commit is contained in:
13
test/closure/close_over_later_variable.wren
Normal file
13
test/closure/close_over_later_variable.wren
Normal file
@ -0,0 +1,13 @@
|
||||
// This is a regression test. There was a bug where if an upvalue for an
|
||||
// earlier local (here "a") was captured *after* a later one ("b"), then Wren
|
||||
// would crash because it walked to the end of the upvalue list (correct), but
|
||||
// then didn't handle not finding the variable.
|
||||
|
||||
new Fn {
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
new Fn {
|
||||
IO.print(b) // expect: b
|
||||
IO.print(a) // expect: a
|
||||
}.call
|
||||
}.call
|
||||
Reference in New Issue
Block a user