Skip to content

Fix stack overflow in checkTypeExpandability()#4565

Open
johnfav03 wants to merge 1 commit into
microsoft:mainfrom
johnfav03:fix-checktypeexpandability-overflow
Open

Fix stack overflow in checkTypeExpandability()#4565
johnfav03 wants to merge 1 commit into
microsoft:mainfrom
johnfav03:fix-checktypeexpandability-overflow

Conversation

@johnfav03

Copy link
Copy Markdown
Contributor

Fixes an issue uncovered in #4380 (comment) (pixijs); checkTypeExpandibility() recurses into a reference type's type arguments, but it only stored the type on the typeStack around the shouldExpandType() calls. This means that self-referential types were never detected as already in-progress and could lead to a stack overflow error.

Copilot AI review requested due to automatic review settings July 8, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 typeStack entry for the full duration of checkTypeExpandability() (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.

@johnfav03 johnfav03 requested a review from jakebailey July 8, 2026 20:00
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.

2 participants