don't be cute

This commit is contained in:
Chris Wanstrath 2025-10-17 12:13:28 -07:00
parent 1a18a713d7
commit 62f890e59d

View File

@ -383,7 +383,6 @@ export class VM {
}) })
break break
// @ts-ignore
case OpCode.TRY_CALL: { case OpCode.TRY_CALL: {
const varName = instruction.operand as string const varName = instruction.operand as string
const value = this.scope.get(varName) const value = this.scope.get(varName)
@ -392,7 +391,9 @@ export class VM {
this.stack.push(value) this.stack.push(value)
this.stack.push(toValue(0)) this.stack.push(toValue(0))
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) { } else if (value) {
this.stack.push(value) this.stack.push(value)
break break
@ -402,8 +403,6 @@ export class VM {
} }
} }
// don't put any `case` statement here - `TRY_CALL` MUST go before `CALL!`
case OpCode.CALL: { case OpCode.CALL: {
// Pop named count from stack (top) // Pop named count from stack (top)
const namedCount = toNumber(this.stack.pop()!) const namedCount = toNumber(this.stack.pop()!)