Fix stack overflow in checkTypeExpandability()#4565
Open
johnfav03 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an infinite-recursion/stack-overflow scenario in the checker’s NodeBuilderImpl.checkTypeExpandability() when encountering self-referential reference-type type arguments during hover/QuickInfo verbosity expansion (pixijs Container pattern; issue #4380).
Changes:
- Keep the
typeStackentry for the full duration ofcheckTypeExpandability()(including recursion into reference type arguments) and add an early cycle short-circuit to prevent unbounded recursion. - Add a new hand-written fourslash regression test reproducing the self-referential default-type-arg loop.
- Add the corresponding quickInfo hover baseline for the new fourslash test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/checker/nodebuilderimpl.go |
Fixes cycle tracking in checkTypeExpandability() so self-referential type arguments don’t recurse indefinitely. |
internal/fourslash/tests/quickinfoVerbositySelfReferentialTypeArg_test.go |
Adds regression coverage for the hover crash pattern from pixijs. |
testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbositySelfReferentialTypeArg.baseline |
Stores expected hover output for the new regression test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue uncovered in #4380 (comment) (pixijs);
checkTypeExpandibility()recurses into a reference type's type arguments, but it only stored the type on thetypeStackaround theshouldExpandType()calls. This means that self-referential types were never detected as already in-progress and could lead to a stack overflow error.