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

Account for RBS untyped functions #2631

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

vinistock
Copy link
Member

Motivation

Closes #2630

According to ruby/rbs#1806, it seems that this new UntypedFunction type represents methods that accept any arguments, but still define some explicit return type.

If my understanding is correct, then it makes sense that the class doesn't implement required_positionals. It accepts anything, there are no parameters to list.

Implementation

Started handling the new class when processing parameters. Note that we need to check for the class' existence to prevent breaking in older RBS versions.

Since we don't index return types, for our purposes an UntypedFunction is just a method that accepts a forward parameter. This is not 100% equivalent, but since we don't have the concept of "accept anything", it's the closest way to represent it.

Automated Tests

Added a test that breaks without 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 Sep 30, 2024
@vinistock vinistock self-assigned this Sep 30, 2024
@vinistock vinistock requested a review from a team as a code owner September 30, 2024 13:37
lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb Outdated Show resolved Hide resolved
@andyw8
Copy link
Contributor

andyw8 commented Sep 30, 2024

FYI @soutaro

@vinistock vinistock force-pushed the vs-account-for-rbs-untyped-functions branch from 7fc52b8 to eefdc2f Compare September 30, 2024 14:12
@vinistock vinistock enabled auto-merge (squash) September 30, 2024 14:13
@vinistock vinistock merged commit f5f4446 into main Sep 30, 2024
38 checks passed
@vinistock vinistock deleted the vs-account-for-rbs-untyped-functions branch September 30, 2024 14:31
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.

Ruby LSP indexing fails with undefined method required_positionals
2 participants