Skip to content

Commit 1307496

Browse files
committed
Assert if a node has been bound more than once
1 parent 8d0c72d commit 1307496

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/compiler/binder.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ namespace ts {
227227
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
228228
const bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
229229

230+
const alreadyBound = new Set<Node>();
231+
230232
/**
231233
* Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file)
232234
* If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node)
@@ -280,6 +282,7 @@ namespace ts {
280282
hasExplicitReturn = false;
281283
inAssignmentPattern = false;
282284
emitFlags = NodeFlags.None;
285+
alreadyBound.clear();
283286
}
284287

285288
return bindSourceFile;
@@ -2373,6 +2376,10 @@ namespace ts {
23732376
if (!node) {
23742377
return;
23752378
}
2379+
2380+
Debug.assert(!alreadyBound.has(node), "This node has already been bound.");
2381+
alreadyBound.add(node);
2382+
23762383
setParent(node, parent);
23772384
if (tracing) (node as TracingNode).tracingPath = file.path;
23782385
const saveInStrictMode = inStrictMode;

0 commit comments

Comments
 (0)