Fix crash bug in closure capturing.

This commit is contained in:
Bob Nystrom
2014-04-24 17:52:53 -07:00
parent 80a4eb8c9c
commit feb9f7cb53
2 changed files with 15 additions and 2 deletions

View 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