Skip to content

Commit

Permalink
Fixed a bug that resulted in an apparent hang within the type printin…
Browse files Browse the repository at this point in the history
…g logic. This was triggered by a pathological case involving a deeply recursive type. This addresses #5594.
  • Loading branch information
msfterictraut committed Jul 29, 2023
1 parent d22b655 commit 7df17e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/pyright-internal/src/analyzer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ export class EnumLiteral {
export type LiteralValue = number | bigint | boolean | string | EnumLiteral;

export type TypeSourceId = number;
export const maxTypeRecursionCount = 32;

// This constant controls the maximum number of nested types (i.e. types
// used as type arguments or parameter types in other types) before we
// give up. This constant was previously set to 32, but there were certain
// pathological recursive types where this resulted in a hang.
export const maxTypeRecursionCount = 10;

export type InheritanceChain = (ClassType | UnknownType)[];

Expand Down

0 comments on commit 7df17e1

Please sign in to comment.