Files
wren/test/language/closure/reuse_closure_slot.wren
T
Bob Nystrom 5fb6186d7d Make constructors just methods.
* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
2015-07-10 09:18:22 -07:00

18 lines
317 B
Plaintext

{
var f = null
{
var a = "a"
f = Fn.new { IO.print(a) }
}
{
// 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"
f.call() // expect: a
}
}
// TODO: Maximum number of closed-over variables (directly and/or indirect).