mlox/lox.t/regression/40.lox
2024-08-03 02:44:12 +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();