Skip to content

Commit

Permalink
fix env push condition (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
NhatMinh0208 authored Apr 3, 2024
1 parent 93f17a1 commit cffe0e7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/cse-machine/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit cffe0e7

Please sign in to comment.