Skip to content

Commit b658879

Browse files
authored
Merge branch 'master' into typed-modules
2 parents 0456c22 + 07f1f87 commit b658879

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-slang",
3-
"version": "1.0.79",
3+
"version": "1.0.80",
44
"license": "Apache-2.0",
55
"description": "Javascript-based implementations of Source, written in Typescript",
66
"keywords": [
@@ -130,5 +130,6 @@
130130
}
131131
]
132132
]
133-
}
133+
},
134+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
134135
}

src/cse-machine/__tests__/__snapshots__/cse-machine-runtime-context.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ exports[`Avoid unnescessary environment instruction 265`] = `5`;
532532

533533
exports[`Avoid unnescessary environment instruction 266`] = `4`;
534534

535-
exports[`Avoid unnescessary environment instruction 267`] = `4`;
535+
exports[`Avoid unnescessary environment instruction 267`] = `5`;
536536

537537
exports[`Avoid unnescessary environment instruction 268`] = `4`;
538538

src/cse-machine/interpreter.ts

Lines changed: 3 additions & 6 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)
@@ -584,14 +583,12 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
584583
// Refer to Source §3 specifications https://docs.sourceacademy.org/source_3.pdf
585584
if (init.type === 'VariableDeclaration' && init.kind === 'let') {
586585
const id = init.declarations[0].id as es.Identifier
587-
const valueExpression = init.declarations[0].init!
588-
589586
control.push(
590587
ast.blockStatement(
591588
[
592589
init,
593590
ast.forStatement(
594-
ast.assignmentExpression(id, valueExpression, command.loc),
591+
ast.assignmentExpression(id, ast.identifier(id.name, command.loc), command.loc),
595592
test,
596593
update,
597594
ast.blockStatement(

0 commit comments

Comments
 (0)