mlox/lox.t/this/nested_closure.lox

19 lines
292 B
Lox
Raw Permalink Normal View History

2024-08-03 02:44:12 +02:00
class Foo {
getClosure() {
fun f() {
fun g() {
fun h() {
return this.toString();
}
return h;
}
return g;
}
return f;
}
toString() { return "Foo"; }
}
var closure = Foo().getClosure();
print closure()()(); // expect: Foo