Skip to content

Introduce ForwardingParam for argument forwarding - #625

Open
Morriar wants to merge 1 commit into
mainfrom
at/forwarding-param-model
Open

Introduce ForwardingParam for argument forwarding#625
Morriar wants to merge 1 commit into
mainfrom
at/forwarding-param-model

Conversation

@Morriar

@Morriar Morriar commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Depends on #624.

Ruby argument forwarding (...) is a distinct parameter form; expanding it to *args, **kwargs, &block loses source fidelity and makes round-tripping impossible.

This PR:

  • Adds RBI::ForwardingParam and wires it through parsing, visitors, RBI/RBS printing, and generated RBI signatures.
  • Skips AddSigTemplates for methods containing ..., since Sorbet does not support signatures on argument-forwarding methods.
  • Treats forwarding params conservatively during merge: foo(...) is compatible with foo(...), but incompatible with expanded *args, **kwargs, &block shapes.

Closes #562.
Closes #578.

@Morriar
Morriar requested a review from a team as a code owner July 9, 2026 20:58
@Morriar
Morriar changed the base branch from main to at-fix-anonymous-params July 9, 2026 21:00
@Morriar Morriar self-assigned this Jul 10, 2026
Comment thread lib/rbi/model.rb
return false unless other.is_a?(Method)
return false unless name == other.name
return false unless params.size == other.params.size
if (params_have_forwarding?(params) || params_have_forwarding?(other.params)) && params != other.params

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why params != other.params?

@Morriar
Morriar force-pushed the at-fix-anonymous-params branch 3 times, most recently from be2225d to 290fc6f Compare July 17, 2026 14:42
Base automatically changed from at-fix-anonymous-params to main July 17, 2026 15:04
Ruby argument forwarding (...) is a distinct parameter form, and expanding it to *args, **kwargs, &block loses source fidelity. Model it explicitly so RBI parsing and printing round-trip forwarding methods.

Add RBI::ForwardingParam and wire it through parser, visitors, printers, and RBS output.
Skip add-sig templates for forwarding methods because Sorbet doesn't support signatures on argument forwarding.
Treat forwarding params as merge-compatible only with the same forwarding shape.

Closes #562.
Closes #578.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
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