diff --git a/src/vm.ts b/src/vm.ts index de679fb..82bbb46 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -383,7 +383,6 @@ export class VM { }) break - // @ts-ignore case OpCode.TRY_CALL: { const varName = instruction.operand as string const value = this.scope.get(varName) @@ -392,7 +391,9 @@ export class VM { this.stack.push(value) this.stack.push(toValue(0)) this.stack.push(toValue(0)) - // No `break` here -- we want to fall through to OpCode.CALL! + this.instructions[this.pc] = { op: OpCode.CALL } + this.pc-- + break } else if (value) { this.stack.push(value) break @@ -402,8 +403,6 @@ export class VM { } } - // don't put any `case` statement here - `TRY_CALL` MUST go before `CALL!` - case OpCode.CALL: { // Pop named count from stack (top) const namedCount = toNumber(this.stack.pop()!)