Support forwarding parameters in method types - #3042
Merged
Merged
Conversation
Morriar
force-pushed
the
support-forwarding-parameters
branch
from
July 28, 2026 21:26
d323e32 to
94176bf
Compare
soutaro
force-pushed
the
support-forwarding-parameters
branch
from
August 4, 2026 07:30
94176bf to
f9f223c
Compare
ksss
pushed a commit
to ksss/rbs
that referenced
this pull request
Aug 14, 2026
`(...)` forwarding parameters (ruby#3042) are syntax-only for now: nothing defines their type checking semantics yet, and distributing signatures that use them would break older parsers and tools that silently drop the node. Introduce `rbs_parser_options_t` and `rbs_parser_new_with_options()` so the syntax must be opted into at the C API level. `rbs_parser_new()` uses the zero-initialized options, which disable every optional syntax, and the Ruby API doesn't expose the option, so `(...)` is a syntax error everywhere in the gem. The AST, types, and serialization support stays in place for when the semantics are settled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015bgoC4byczqmYRzNrDkVrL
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add parser and AST support for Ruby-style forwarding parameters in RBS method types.
RBS already uses
...to retain existing overloads:def foo: (Integer) -> String | ...The two forms are unambiguous because forwarding appears inside a parameter list, while overload continuation appears where a method type is expected.
Implementation
Represent forwarding as an optional
RBS::Types::Function::ForwardingParamnode:The node preserves the location of
...for diagnostics and syntax-aware tooling:The change updates:
Syntax restrictions
Forwarding must be the final parameter and may only follow required positional parameters.
Accepted:
Rejected:
Forwarding is also rejected in Proc and block parameter types:
Because forwarding includes the block, an additional explicit block is rejected:
(...) { () -> void } -> void (...) ?{ () -> void } -> voidThe existing overload-continuation syntax continues to work alongside forwarding: