Skip to content

Commit fa1323c

Browse files
committed
Compile incrementors within the initializer's flow in for loops
It turns out that incrementors were compiled with the body's flow, which meant that the incrementor had access to local variables declared in the body. Now, code like this should no longer compile: for (let i = 0; i < 2; j++) { let j = 0; } Fixes AssemblyScript#2825.
1 parent de174c5 commit fa1323c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: src/compiler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,7 @@ export class Compiler extends DiagnosticEmitter {
26002600
if (possiblyLoops) {
26012601
let incrementor = statement.incrementor;
26022602
if (incrementor) {
2603+
this.currentFlow = flow;
26032604
bodyStmts.push(
26042605
this.compileExpression(incrementor, Type.void, Constraints.ConvImplicit | Constraints.WillDrop)
26052606
);

0 commit comments

Comments
 (0)