Skip to content

Commit 80e6df6

Browse files
committed
Stricter circular recursion check in type inference
1 parent 355706d commit 80e6df6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19600,16 +19600,16 @@ namespace ts {
1960019600
// We stop inferring and report a circularity if we encounter duplicate recursion identities on both
1960119601
// the source side and the target side.
1960219602
const saveExpandingFlags = expandingFlags;
19603-
const sourceIdentity = getRecursionIdentity(source);
19604-
const targetIdentity = getRecursionIdentity(target);
19605-
if (sourceIdentity && contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source;
19606-
if (targetIdentity && contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target;
19603+
const sourceIdentity = getRecursionIdentity(source) || source;
19604+
const targetIdentity = getRecursionIdentity(target) || target;
19605+
if (contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source;
19606+
if (contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target;
1960719607
if (expandingFlags !== ExpandingFlags.Both) {
19608-
if (sourceIdentity) (sourceStack || (sourceStack = [])).push(sourceIdentity);
19609-
if (targetIdentity) (targetStack || (targetStack = [])).push(targetIdentity);
19608+
(sourceStack || (sourceStack = [])).push(sourceIdentity);
19609+
(targetStack || (targetStack = [])).push(targetIdentity);
1961019610
action(source, target);
19611-
if (targetIdentity) targetStack.pop();
19612-
if (sourceIdentity) sourceStack.pop();
19611+
targetStack.pop();
19612+
sourceStack.pop();
1961319613
}
1961419614
else {
1961519615
inferencePriority = InferencePriority.Circularity;

0 commit comments

Comments
 (0)