10000 Add autocorrect for RBS parameter kinds by Morriar · Pull Request #8857 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add autocorrect for RBS parameter kinds #8857

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

Merged
merged 2 commits into from
May 14, 2025

Conversation

Morriar
Copy link
Collaborator
@Morriar Morriar commented May 9, 2025

Motivation

Add an autocorrect for 3556 error code so when the kinds of the parameters mismatch between the RBS sig and the method definition like this:

#: (?Integer, y: Integer, **Integer) -> void
#    ^^^^^^^ error: Argument kind mismatch for `x`, method declares `positional`, but RBS signature declares `optional positional`
#             ^^^^^^^^^^ error: Argument kind mismatch for `y`, method declares `optional positional`, but RBS signature declares `keyword`
#                           ^^^^^^^ error: Argument kind mismatch for `z`, method declares `rest positional`, but RBS signature declares `rest keyword`
def foo(x, y = 42, *z); end

The RBS signature gets autocorrected when running srb tc --isolate-error-code 2556 -a:

#: (Integer, ?Integer y, *Integer) -> void
def foo(x, y = 42, *z); end

The autocorrect does not correct blocks yet:

#: (Integer) -> void
#   ^^^^^^^ error: Argument kind mismatch for `x`, method declares `block`, but RBS signature declares `positional`
def block1(&x); end

#: { -> void } -> void
#  ^^^^^^^^^^^ error: Argument kind mismatch for `x`, method declares `positional`, but RBS signature declares `block`
def block2(x); end

Test plan

See included automated tests.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar requested a review from a team as a code owner May 9, 2025 20:59
@Morriar Morriar requested review from froydnj and removed request for a team May 9, 2025 20:59
@Morriar Morriar self-assigned this May 9, 2025
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar force-pushed the at-rbs-autocorrect-params branch from 228298b to 9b4b2e5 Compare May 9, 2025 21:02
Copy link
Contributor
@froydnj froydnj left a comment

Choose a reason for hiding this comment

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

Sorry for dropping this on the floor, I lost context on this over the weekend.

@froydnj froydnj merged commit 9dba463 into sorbet:master May 14, 2025
14 checks passed
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
0