Skip to content

Commit 6b1ea96

Browse files
authored
Fix flow node improper reuse (#60662)
1 parent 9bf5aa7 commit 6b1ea96

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/compiler/binder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
BreakOrContinueStatement,
2222
CallChain,
2323
CallExpression,
24+
canHaveFlowNode,
2425
canHaveLocals,
2526
canHaveSymbol,
2627
CaseBlock,
@@ -1104,6 +1105,9 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
11041105
// and set it before we descend into nodes that could actually be part of an assignment pattern.
11051106
inAssignmentPattern = false;
11061107
if (checkUnreachable(node)) {
1108+
if (canHaveFlowNode(node) && node.flowNode) {
1109+
node.flowNode = undefined;
1110+
}
11071111
bindEachChild(node);
11081112
bindJSDoc(node);
11091113
inAssignmentPattern = saveInAssignmentPattern;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// function test() {
4+
//// return/*a*/abc();
5+
//// return;
6+
//// }
7+
//// function abc() { }
8+
9+
verify.numberOfErrorsInCurrentFile(1);
10+
11+
goTo.marker("a")
12+
edit.insert(" ");
13+
verify.noErrors();

0 commit comments

Comments
 (0)