Skip to content

Fix infinite constraints #26558

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

Merged
merged 8 commits into from
Aug 22, 2018
Merged

Fix infinite constraints #26558

merged 8 commits into from
Aug 22, 2018

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Aug 20, 2018

This PR introduces recursion depth limiters in instantiateType and getImmediateBaseConstraint to stop infinite recursion caused by certain patterns of mapped types and index access types in constraints. The PR also removes a similar check from getTypeOfInstantiatedSymbol that was rendered unnecessary by other fixes (no baseline changes result from removing this check and the original repro is now reported as a circularity error).

The PR additionally modifies getConstraintOfDistributiveConditionalType to only obtain the constraint of the given type when simplification yields the same type (i.e. when simplification isn't possible).

Fixes #22950.
Fixes #26448.

@weswigham
Copy link
Member

weswigham commented Aug 20, 2018

@typescript-bot test this, thanks (just to check that 50 is sufficient for all our real world code)

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2018

Heya @weswigham, I've started to run the extended test suite on this PR at a15fecd. You can monitor the build here. It should now contribute to this PR's status checks.

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No diffs from master on RWC, so seems good.

@ahejlsberg ahejlsberg merged commit 93c76cb into master Aug 22, 2018
@ahejlsberg ahejlsberg deleted the fixInfiniteConstraints branch August 22, 2018 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack overflow with circular mapped type and conditional type Maximum call stack size exceeded while inferring conditional type.
4 participants