Skip to content

Compiler stack overflow with circular constraint and conditional type #25740

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

Closed
mattmccutchen opened this issue Jul 17, 2018 · 0 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mattmccutchen
Copy link
Contributor

I triggered this while trying to use the type system to verify that I was interning objects properly. I can provide the real-world example code if it's of interest.

TypeScript Version: master (d9ed917)

Search Terms: "Maximum call stack size exceeded" and some of the function names from the stack trace below.

Code

type Foo<T> = [T] extends [number] ? {} : {};
function foo<S extends Foo<S>>() {}

Expected behavior: No compiler crash.

Actual behavior:

REDACTED/typescript/built/local/tsc.js:83260
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at getSymbol (REDACTED/typescript/built/local/tsc.js:30038:27)
    at resolveNameHelper (REDACTED/typescript/built/local/tsc.js:30201:34)
    at resolveName (REDACTED/typescript/built/local/tsc.js:30187:20)
    at resolveEntityName (REDACTED/typescript/built/local/tsc.js:31026:26)
    at resolveTypeReferenceName (REDACTED/typescript/built/local/tsc.js:36544:20)
    at getTypeFromTypeReference (REDACTED/typescript/built/local/tsc.js:36706:30)
    at getTypeFromTypeNode (REDACTED/typescript/built/local/tsc.js:38062:28)
    at getConstraintFromTypeParameter (REDACTED/typescript/built/local/tsc.js:36389:72)
    at isUnconstrainedTypeParameter (REDACTED/typescript/built/local/tsc.js:40346:63)
    at REDACTED/typescript/built/local/tsc.js:40349:121
    at Object.some (REDACTED/typescript/built/local/tsc.js:626:25)
    at isTypeReferenceWithGenericArguments (REDACTED/typescript/built/local/tsc.js:40349:74)
    at getRelationKey (REDACTED/typescript/built/local/tsc.js:40387:17)
    at recursiveTypeRelatedTo (REDACTED/typescript/built/local/tsc.js:39623:26)
    at isRelatedTo (REDACTED/typescript/built/local/tsc.js:39305:38)
    at checkTypeRelatedTo (REDACTED/typescript/built/local/tsc.js:39096:26)
    at getConditionalType (REDACTED/typescript/built/local/tsc.js:37671:21)
    at instantiateConditionalType (REDACTED/typescript/built/local/tsc.js:38415:20)
    at getConditionalTypeInstantiation (REDACTED/typescript/built/local/tsc.js:38397:30)
    at instantiateType (REDACTED/typescript/built/local/tsc.js:38456:28)
    at getTypeAliasInstantiation (REDACTED/typescript/built/local/tsc.js:36500:62)
    at getTypeFromTypeAliasReference (REDACTED/typescript/built/local/tsc.js:36521:24)
    at getTypeReferenceTypeWorker (REDACTED/typescript/built/local/tsc.js:36598:24)
    at getTypeReferenceType (REDACTED/typescript/built/local/tsc.js:36551:24)
    at getTypeFromTypeReference (REDACTED/typescript/built/local/tsc.js:36707:28)
    at getTypeFromTypeNode (REDACTED/typescript/built/local/tsc.js:38062:28)
    at getConstraintFromTypeParameter (REDACTED/typescript/built/local/tsc.js:36389:72)
    at isUnconstrainedTypeParameter (REDACTED/typescript/built/local/tsc.js:40346:63)
    at REDACTED/typescript/built/local/tsc.js:40349:121
    at Object.some (REDACTED/typescript/built/local/tsc.js:626:25)
...

Playground Link: link

Related Issues: #22950 conceivably but probably not.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 17, 2018
@mhegazy mhegazy assigned weswigham and ahejlsberg and unassigned weswigham Jul 17, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 17, 2018
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants