Fix bug with upvalues
This commit is contained in:
parent
eaf5e9a30a
commit
c9a0a5560d
@ -1,7 +1,9 @@
|
|||||||
|
local b = 5
|
||||||
|
|
||||||
function add(x)
|
function add(x)
|
||||||
return function (y)
|
return function (y)
|
||||||
x = x + 1
|
x = x + 1
|
||||||
return x + y, 1, 2
|
return x + y, 1, 2, b
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -343,8 +343,9 @@ impl Expression {
|
|||||||
inner_scope.highest_upvalue = scope.highest_upvalue + scope.register_counter.0;
|
inner_scope.highest_upvalue = scope.highest_upvalue + scope.register_counter.0;
|
||||||
inner_scope.upvalues = scope.upvalues.clone();
|
inner_scope.upvalues = scope.upvalues.clone();
|
||||||
|
|
||||||
|
dbg!(&scope.locals);
|
||||||
for (name, reg) in &scope.locals {
|
for (name, reg) in &scope.locals {
|
||||||
let new_reg = *reg + inner_scope.highest_upvalue;
|
let new_reg = *reg + scope.highest_upvalue + 1;
|
||||||
inner_scope.upvalues.insert(name.clone(), new_reg);
|
inner_scope.upvalues.insert(name.clone(), new_reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user