From bd1736b474b1f3d89c4095dbfa0ff8d858f91241 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Wed, 5 Nov 2025 15:20:55 -0800 Subject: [PATCH] toValue is hungry --- src/vm.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vm.ts b/src/vm.ts index 667e41b..f342a6b 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -253,7 +253,7 @@ export class VM { const value = this.scope.get(varName) if (value === undefined) - this.stack.push(toValue(varName)) + this.stack.push(toValue(varName, this)) else this.stack.push(value) @@ -455,10 +455,10 @@ export class VM { const target = this.stack.pop()! if (target.type === 'array') - this.stack.push(toValue(target.value?.[Number(index.value)])) + this.stack.push(toValue(target.value?.[Number(index.value)], this)) else if (target.type === 'dict') - this.stack.push(toValue(target.value?.get(String(index.value)))) + this.stack.push(toValue(target.value?.get(String(index.value)), this)) else throw new Error(`DOT_GET: ${target.type} not supported`) @@ -590,7 +590,7 @@ export class VM { } // Convert dict to plain JavaScript object for the native function const namedObj = fromValue({ type: 'dict', value: namedDict }, this) - nativeArgs.push(toValue(namedObj)) + nativeArgs.push(toValue(namedObj, this)) } // Handle variadic parameter (TypeScript rest parameters) @@ -834,6 +834,6 @@ export class VM { } const result = await originalFn.call(this, ...args) - return toValue(result) + return toValue(result, this) } } \ No newline at end of file