rlox/interpreter/tests/lox/regression/40.lox
2024-09-01 19:15:55 +02:00

22 lines
362 B
Lox

fun caller(g) {
g();
// g should be a function, not nil.
print g == nil; // expect: false
}
fun callCaller() {
var capturedVar = "before";
var a = "a";
fun f() {
// Commenting the next line out prevents the bug!
capturedVar = "after";
// Returning anything also fixes it, even nil:
//return nil;
}
caller(f);
}
callCaller();