From cffe0e70202be28d8d2cb8f3cb2ee7c9faa5f1f3 Mon Sep 17 00:00:00 2001 From: Theoth Normie Date: Wed, 3 Apr 2024 16:42:01 +0800 Subject: [PATCH] fix env push condition (#1639) --- src/cse-machine/interpreter.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cse-machine/interpreter.ts b/src/cse-machine/interpreter.ts index 3e904e90c..ec5a56d44 100644 --- a/src/cse-machine/interpreter.ts +++ b/src/cse-machine/interpreter.ts @@ -974,12 +974,9 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = { const next = control.peek() - // Push ENVIRONMENT instruction if needed - if next instruction - // is empty or not an environment instruction - if ( - !next || - (!(isInstr(next) && next.instrType === InstrType.ENVIRONMENT) && !control.isEmpty()) - ) { + // Push ENVIRONMENT instruction if needed - if next control stack item + // exists and is not an environment instruction + if (next && !(isInstr(next) && next.instrType === InstrType.ENVIRONMENT)) { control.push(instr.envInstr(currentEnvironment(context), command.srcNode)) }