Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler hangs #31823

Closed
falsandtru opened this issue Jun 8, 2019 · 4 comments · Fixed by #32079
Closed

Compiler hangs #31823

falsandtru opened this issue Jun 8, 2019 · 4 comments · Fixed by #32079
Assignees
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior

Comments

@falsandtru
Copy link
Contributor

But looks like CPU and Memory usage is not increasing.

TypeScript Version: master

Search Terms:

Code

export type Prepend<Elm, T extends unknown[]> =
  T extends unknown ?
  ((arg: Elm, ...rest: T) => void) extends ((...args: infer T2) => void) ? T2 :
  never :
  never;
export type ExactExtract<T, U> = T extends U ? U extends T ? T : never : never;

type Conv<T, U = T> =
  { 0: [T]; 1: Prepend<T, Conv<ExactExtract<U, T>>>;}[U extends T ? 0 : 1];

Expected behavior:

pass

Actual behavior:

hang

Playground Link:

Related Issues:

@sandersn
Copy link
Member

Also fails on 3.5.1

@sandersn sandersn added Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior labels Jun 11, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@weswigham
Copy link
Member

The type expands so well:

image

I'm actually surprised we just hang rather than quickly OOM. Apparently a Conv<ExactExtract<U, T>> is not a simple type, and determining if it's assignable to an unknown[] is not so easy. :P

@fatcerberus
Copy link

@weswigham Wait, why does that type expand recursively like that? Shouldn't that have been caught by the instantiation depth limiter?

@weswigham
Copy link
Member

Oh, it is. The depth limit is 50 instances of the same type and there's like 10 different types, so that's like 500 types deep that it can easily go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior
Projects
None yet
5 participants