Skip to content

Commit 3040201

Browse files
committed
Fixed bug in for loops
1 parent 8ead9f2 commit 3040201

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cse-machine/interpreter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
584584
// Refer to Source §3 specifications https://docs.sourceacademy.org/source_3.pdf
585585
if (init.type === 'VariableDeclaration' && init.kind === 'let') {
586586
const id = init.declarations[0].id as es.Identifier
587-
const valueExpression = init.declarations[0].init!
587+
// const valueExpression = init.declarations[0].init!
588588

589589
control.push(
590590
ast.blockStatement(
591591
[
592592
init,
593593
ast.forStatement(
594-
ast.assignmentExpression(id, valueExpression, command.loc),
594+
ast.assignmentExpression(id, ast.identifier(id.name, command.loc), command.loc),
595595
test,
596596
update,
597597
ast.blockStatement(

0 commit comments

Comments
 (0)