Skip to content

Conversation

@pkondzior
Copy link
Contributor

@pkondzior pkondzior commented Oct 13, 2025

Motivation

Closes #3782

Fixes a SystemStackError that occurred when resolving certain constant aliases. When a nested module defines a constant alias referencing another constant of the same short name in an outer namespace (for example, B = B::C inside A::D), the Ruby LSP indexer entered infinite recursion because seen_names was not propagated to follow_aliased_namespace.

Implementation

Pass seen_names from direct_or_aliased_constant into follow_aliased_namespace to enable proper cycle detection.

Automated Tests

Added a regression test test_resolving_self_referential_constant_alias covering the B = B::C case.

Manual Tests

  1. Open VS Code with Ruby LSP enabled.
  2. Create a file test.rb:
module A
 module B
   class C
   end
 end
end

module A
 module D
   B = B::C
 end
end
  1. Trigger Go to Definition or hover over B inside A::D.
    4.Expected: No crash. B correctly resolves to A::B::C.

@graphite-app
Copy link

graphite-app bot commented Oct 13, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@pkondzior pkondzior marked this pull request as ready for review October 13, 2025 20:47
@pkondzior pkondzior requested a review from a team as a code owner October 13, 2025 20:47
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! And good catch

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Oct 14, 2025
@pkondzior pkondzior requested a review from vinistock October 14, 2025 14:32
@pkondzior pkondzior requested a review from vinistock October 15, 2025 12:32
@pkondzior pkondzior requested a review from vinistock October 15, 2025 15:01
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

@vinistock vinistock merged commit b2afe05 into Shopify:main Oct 15, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack overflow when resolving self-referential constant alias

2 participants