Fix bug with upvalues

This commit is contained in:
Sofia 2026-03-16 15:44:24 +02:00
parent eaf5e9a30a
commit c9a0a5560d
2 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,9 @@
local b = 5
function add(x)
return function (y)
x = x + 1
return x + y, 1, 2
return x + y, 1, 2, b
end
end

View File

@ -343,8 +343,9 @@ impl Expression {
inner_scope.highest_upvalue = scope.highest_upvalue + scope.register_counter.0;
inner_scope.upvalues = scope.upvalues.clone();
dbg!(&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);
}