Skip to content

Commit

Permalink
Always set last type id
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Oct 30, 2021
1 parent 86185ad commit 52e10d3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20366,12 +20366,14 @@ namespace ts {
let lastTypeId = 0;
for (let i = 0; i < depth; i++) {
const t = stack[i];
// We only count occurrences with higher type ids than the previous occurrences, since higher
// type ids are an indicator of newer instantiations caused by recursion.
if (getRecursionIdentity(t) === identity && t.id >= lastTypeId) {
count++;
if (count >= maxDepth) {
return true;
if (getRecursionIdentity(t) === identity) {
// We only count occurrences with a higher type id than the previous occurrence, since higher
// type ids are an indicator of newer instantiations caused by recursion.
if (t.id >= lastTypeId) {
count++;
if (count >= maxDepth) {
return true;
}
}
lastTypeId = t.id;
}
Expand Down

0 comments on commit 52e10d3

Please sign in to comment.