mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
added lox test files
This commit is contained in:
parent
821f5c62bc
commit
0f3d0a15f0
268 changed files with 7497 additions and 3 deletions
28
lox.t/closure/unused_later_closure.lox
Normal file
28
lox.t/closure/unused_later_closure.lox
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// This is a regression test. When closing upvalues for discarded locals, it
|
||||
// wouldn't make sure it discarded the upvalue for the correct stack slot.
|
||||
//
|
||||
// Here we create two locals that can be closed over, but only the first one
|
||||
// actually is. When "b" goes out of scope, we need to make sure we don't
|
||||
// prematurely close "a".
|
||||
var closure;
|
||||
|
||||
{
|
||||
var a = "a";
|
||||
|
||||
{
|
||||
var b = "b";
|
||||
fun returnA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
closure = returnA;
|
||||
|
||||
if (false) {
|
||||
fun returnB() {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print closure(); // expect: a
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue