Skip to content

Port TypeScript #63026: Fix crash from circularly-reentrant getEffectsSignature#2754

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-circular-reentrant-crash
Closed

Port TypeScript #63026: Fix crash from circularly-reentrant getEffectsSignature#2754
Copilot wants to merge 3 commits intomainfrom
copilot/fix-circular-reentrant-crash

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Ports microsoft/TypeScript#63026

Function-like type-level nodes (call signatures, function types, etc.) need their own detached flow node via IsControlFlowContainer to prevent typeof queries within them from being narrowed by the containing container's flow graph. Without this, code like the following triggers infinite recursion through getEffectsSignature:

unionOfDifferentReturnType1(true);
const unionOfDifferentReturnType1: { (a: any): number; } | { (a: number): typeof Date; };

The Go binder already had IsControlFlowContainer on these nodes (unlike the TS side which had temporarily lost it), but was missing the seenThisKeyword save/restore/propagation logic that the TS fix introduced.

Changes

  • New ContainerFlagsPropagatesThisKeyword flag (1 << 9) — marks containers that should propagate seenThisKeyword upward (arrow functions, method/call/construct signatures, function/constructor types)
  • seenThisKeyword lifecycle in IsControlFlowContainer branch — save, reset before bindChildren, set ContainsThis after, and conditionally propagate via PropagatesThisKeyword
  • Clear NodeFlagsContainsThis alongside reachability flags during incremental reset, matching TS behavior
  • Updated GetContainerFlags to apply PropagatesThisKeyword to MethodSignature, CallSignature, FunctionType, ConstructSignature, ConstructorType, and ArrowFunction

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ectsSignature

Add PropagatesThisKeyword container flag and seenThisKeyword save/restore
logic in IsControlFlowContainer branch to prevent infinite recursion when
typeof queries in function-like type nodes trigger getEffectsSignature.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix crash caused by circularly-reentrant getEffectsSignature Port TypeScript #63026: Fix crash from circularly-reentrant getEffectsSignature Feb 11, 2026
Copilot AI requested a review from jakebailey February 11, 2026 01:04
@jakebailey
Copy link
Member

Nothing seems to change, confusingly

@jakebailey
Copy link
Member

I think this needs #2748 to make sense, or rather, this may be a noop after.

@jakebailey jakebailey closed this Feb 12, 2026
@jakebailey jakebailey deleted the copilot/fix-circular-reentrant-crash branch February 12, 2026 19:01
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