Skip to content

Add support for top-level bind in sigs - #645

Merged
Morriar merged 6 commits into
mainfrom
support-top-level-sig-bind
Aug 5, 2026
Merged

Add support for top-level bind in sigs#645
Morriar merged 6 commits into
mainfrom
support-top-level-sig-bind

Conversation

@Morriar

@Morriar Morriar commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Add support for Sorbet’s top-level bind signature modifier:

sig { bind(Foo).params(value: String).returns(Symbol) }

Previously, the parser silently discarded bind(Foo).

  • store the bind type on RBI::Sig

  • parse and print bind(...) when round-tripping RBI

  • normalize braceless shape bind types:

    sig { bind("foo" => Integer).void }

    becomes:

    sig { bind({"foo" => Integer}).void }
  • include bind types in signature equality and merge behavior

  • preserve bind types when rewriting attributes into methods

  • share type-argument extraction between bind and returns

RBS output intentionally omits top-level bind. Sorbet uses it to set the type of self while checking the method body, and RBS has no equivalent method-level self binding.

@Morriar
Morriar requested a review from a team as a code owner August 4, 2026 19:48

@paracycle paracycle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I actually didn't know that you could do a top-level bind call like this either.

Support braceless shape types in T::Struct fields
@Morriar
Morriar merged commit c1f1390 into main Aug 5, 2026
11 checks passed
@Morriar
Morriar deleted the support-top-level-sig-bind branch August 5, 2026 13:23
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