Skip to content

Commit

Permalink
vm: resolve upvalues before pushing them onto the stack
Browse files Browse the repository at this point in the history
Commit e5fe6b1 ("treewide: refactor vector usage code") accidentially dropped
the upvalue resolving logic from uc_vm_stack_push(), leading to unresolved
upvalues leaking into the script execution context.

Fixes: e5fe6b1 ("treewide: refactor vector usage code")
Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- committed Nov 29, 2024
1 parent 3408edf commit 44cd800
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions tests/custom/99_bugs/50_missing_upvalue_resolving
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Commit e5fe6b1 ("treewide: refactor vector usage code") accidentially dropped
the upvalue resolving logic from uc_vm_stack_push(), leading to unresolved
upvalues leaking into the script execution context.

-- File test.uc --
export let obj = { foo: true, bar: false };
-- End --

-- Testcase --
import * as test from "./files/test.uc";

printf("%.J\n", [
type(test.obj),
test.obj.foo
]);
-- End --

-- Args --
-R
-- End --

-- Expect stdout --
[
"object",
true
]
-- End --
2 changes: 1 addition & 1 deletion vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ uc_vm_resolve_upval(uc_vm_t *vm, uc_value_t *value)
void
uc_vm_stack_push(uc_vm_t *vm, uc_value_t *value)
{
uc_vector_push(&vm->stack, value);
uc_vector_push(&vm->stack, uc_vm_resolve_upval(vm, value));

if (vm->trace) {
fprintf(stderr, " [+%zd] %s\n",
Expand Down

0 comments on commit 44cd800

Please sign in to comment.