Skip to content
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

Protect method resolution from circular aliases #2499

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

vinistock
Copy link
Member

Motivation

Closes #2497

We had a small level of protection against circular method aliases, but it was not enough for the case presented in the issue.

We need to keep track of seen_names, just like we do for constant aliases, in order to prevent trying to re-process a name we're already found.

Implementation

Added the seen_names array for method aliases, which returns early before trying to recurse more if we find a name we've already seen.

Automated Tests

Added a test that fails before the fix.

@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 Aug 28, 2024
@vinistock vinistock self-assigned this Aug 28, 2024
@vinistock vinistock requested a review from a team as a code owner August 28, 2024 13:58
@vinistock vinistock requested review from andyw8 and st0012 August 28, 2024 13:58
@vinistock vinistock added blocked This issue can't move forward until a blocker is resolved and removed blocked This issue can't move forward until a blocker is resolved labels Aug 28, 2024
@vinistock vinistock merged commit 3456ec7 into main Aug 28, 2024
41 checks passed
@vinistock vinistock deleted the vs-fix-circular-alias-loop branch August 28, 2024 16:05
inherited_only: T::Boolean,
).returns(T.nilable(T::Array[T.any(Entry::Member, Entry::MethodAlias)]))
end
def resolve_method(method_name, receiver_name, inherited_only: false)
def resolve_method(method_name, receiver_name, seen_names = [], inherited_only: false)
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but I feel these optional args would better be keyword args instead.

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.

SystemStackError during document completion with alias "loop"
3 participants