Skip to content

Commit

Permalink
Fix flow node improper reuse (#60662)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabritto authored Dec 4, 2024
1 parent 9bf5aa7 commit 6b1ea96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
BreakOrContinueStatement,
CallChain,
CallExpression,
canHaveFlowNode,
canHaveLocals,
canHaveSymbol,
CaseBlock,
Expand Down Expand Up @@ -1104,6 +1105,9 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
// and set it before we descend into nodes that could actually be part of an assignment pattern.
inAssignmentPattern = false;
if (checkUnreachable(node)) {
if (canHaveFlowNode(node) && node.flowNode) {
node.flowNode = undefined;
}
bindEachChild(node);
bindJSDoc(node);
inAssignmentPattern = saveInAssignmentPattern;
Expand Down
13 changes: 13 additions & 0 deletions tests/cases/fourslash/unreachableStatementNodeReuse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts" />

//// function test() {
//// return/*a*/abc();
//// return;
//// }
//// function abc() { }

verify.numberOfErrorsInCurrentFile(1);

goTo.marker("a")
edit.insert(" ");
verify.noErrors();

0 comments on commit 6b1ea96

Please sign in to comment.