Files
wren/test/language/closure/reuse_closure_slot.wren
T

18 lines
317 B
Plaintext
Raw Normal View History

2013-12-04 07:43:50 -08:00
{
var f = null
{
var a = "a"
2015-07-10 09:18:22 -07:00
f = Fn.new { IO.print(a) }
2013-12-04 07:43:50 -08:00
}
{
// Since a is out of scope, the local slot will be reused by b. Make sure
// that f still closes over a.
var b = "b"
2015-02-26 23:08:36 -08:00
f.call() // expect: a
2013-12-04 07:43:50 -08:00
}
}
// TODO: Maximum number of closed-over variables (directly and/or indirect).