Skip to content

Commit 805972d

Browse files
committed
improve comment
1 parent 1ed6890 commit 805972d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/compiler/binder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,11 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
15411541
function bindForStatement(node: ForStatement): void {
15421542
bind(node.initializer);
15431543
if (currentFlow === unreachableFlow) {
1544-
// follow what `bindChildren` already does for `unreachableFlow`
1545-
// given `node.initializer` was already bound we have to manually bind the rest of the statement instead of relying on `bindEach`
1544+
// Unlike while/do, the for-loop initializer is bound inside this function before the loop's
1545+
// flow graph is constructed. If it makes flow unreachable (e.g. a throwing IIFE), addAntecedent
1546+
// will filter out the unreachable entry to preLoopLabel, leaving only the back-edge from the
1547+
// incrementor. This creates a cycle with no exit that crashes isReachableFlowNodeWorker.
1548+
// Bail out early and just bind the remaining children with unreachable flow.
15461549
bind(node.condition);
15471550
bind(node.statement);
15481551
bind(node.incrementor);

0 commit comments

Comments
 (0)