Skip to content

Commit

Permalink
fix: Mitigate endless loop in (invalid) override discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Jan 8, 2023
1 parent c9297db commit d46bfeb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ export class Program extends DiagnosticEmitter {
let thisInstanceMembers = thisPrototype.instanceMembers;
if (thisInstanceMembers) {
let thisMembers = Map_values(thisInstanceMembers);
let seen: Set<ClassPrototype> | null = null;
do {
let baseInstanceMembers = basePrototype.instanceMembers;
if (baseInstanceMembers) {
Expand All @@ -1525,6 +1526,11 @@ export class Program extends DiagnosticEmitter {
}
let nextPrototype = basePrototype.basePrototype;
if (!nextPrototype) break;
// Break on circular inheritance. Is diagnosed later, when resolved.
if (!seen) seen = new Set();
seen.add(basePrototype);
if (seen.has(nextPrototype)) break;
// Otherwise traverse to next base prototype.
basePrototype = nextPrototype;
} while (true);
}
Expand Down

0 comments on commit d46bfeb

Please sign in to comment.