Skip to content

Skip assigned T.bind assertion translations - #996

Open
Morriar wants to merge 1 commit into
mainfrom
at/skip-assignment-bind
Open

Skip assigned T.bind assertion translations#996
Morriar wants to merge 1 commit into
mainfrom
at/skip-assignment-bind

Conversation

@Morriar

@Morriar Morriar commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Why?

Given this Sorbet assertion:

bound = T.bind(self, FulfillmentOrderMoverTest)

spoom srb assertions translate currently produces:

bound = #: self as FulfillmentOrderMoverTest

This is invalid Ruby. Unlike T.let and T.cast, T.bind translates to a standalone RBS comment and leaves no expression that can remain on the right-hand side of the assignment. Until there is a safe translation for that shape, assignment-wrapped T.bind calls should be left unchanged.

What changed?

  • Leave assignment-wrapped T.bind calls unchanged for now.
  • Add regression coverage for the failing assignment case.

@Morriar
Morriar requested a review from a team as a code owner August 5, 2026 20:41

def test_skip_bind_in_assignment
rb = <<~RB
bound = T.bind(self, FulfillmentOrderMoverTest)

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.

Wouldn't it be better to rewrite this to:

bound = self #: self as FulfillmentOrderMoverTest

instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

We can rewrite to:

#: self as FulfillmentOrderMoverTest
bound = self

though, and that seems to work for both requirements: https://sorbet.run/?arg=--parser=prism&arg=--enable-experimental-rbs-comments#%23%20typed%3A%20true%0A%0A%23%3A%20self%20as%20Integer%0Afoo%20%3D%20self%0A%0AT.reveal_type%28foo%29

@Morriar
Morriar requested a review from paracycle August 6, 2026 15:26
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