Skip to content

Commit dd053a6

Browse files
committed
Fix bugs in for loops and block exec
1 parent 5630d26 commit dd053a6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/cse-machine/interpreter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,8 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
499499
}
500500

501501
if (command.body.length == 1) {
502-
// If program only consists of one statement, evaluate it immediately
503-
const next = command.body[0]
504-
cmdEvaluators[next.type](next, context, control, stash, isPrelude)
502+
// If program only consists of one statement, unwrap outer block
503+
control.push(...handleSequence(command.body))
505504
} else {
506505
// Push block body as statement sequence
507506
const seq: StatementSequence = ast.statementSequence(command.body, command.loc)

0 commit comments

Comments
 (0)