Skip to content

Conversation

@KaanOzkan
Copy link

@KaanOzkan KaanOzkan commented Sep 2, 2025

Motivation

#573

Test plan

See included automated tests.

Copy link
Author

KaanOzkan commented Sep 2, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@KaanOzkan KaanOzkan changed the title Necessary plumbing Migrate RBS rewriter to handle Prism AST Sep 2, 2025
@KaanOzkan KaanOzkan force-pushed the ko/rbs-over-prism branch 2 times, most recently from d4d7999 to f5f7118 Compare September 2, 2025 15:09
@KaanOzkan KaanOzkan changed the title Migrate RBS rewriter to handle Prism AST [WIP] Migrate RBS rewriter to handle Prism AST Sep 2, 2025
@KaanOzkan KaanOzkan force-pushed the ko/rbs-over-prism branch 3 times, most recently from 7b47aa3 to d4cb18f Compare September 3, 2025 21:15
@KaanOzkan KaanOzkan mentioned this pull request Nov 24, 2025
10 tasks
allcre and others added 19 commits December 12, 2025 16:31
This fixes a few RBS rewriter issues we saw when running against core:

Fix binding assertions inside blocks:
  
  ```rb
  foo do
    #: self as Foo
  end
  ```

Add handling for binding assertions inside lambdas:

  ```rb
  FOO = -> {
    #: self as Foo
  }
  ```

Add handling for various assignments such as `&&=` and `||=`.
…nization (#808)

<!-- (optional) Explain your change, focusing on the details of the solution. This is a great place to call out user-visible changes. -->

### Part of #764
These should be collected after requireds and optionals, as per the
original behavior in ``MethodTypeToParserNode.cc``.
This PR fixes a couple of issues I saw when running the integration
branch in core:

- Adds `SorbetPrivateStaticVoid` to resolve to
`::Sorbet::Private::Static::Void` instead of `T.void`. This fixes
`Unable to resolve constant T.void` errors.
- Adds missing `Enumerator::Lazy` and `Enumerator::Chain` constants,
copying the logic directly from the original `TypeToParserNode.cc`. This
fixes `Use T::Enumerator::Lazy[...], not Enumerator::Lazy[...] to
declare a typed Enumerator::Lazy` errors.
These should be collected after required, optional, and rest
positionals, as per the original behavior in
`MethodTypeToParserNode.cc`:
https://github.com/Shopify/sorbet/blob/9fb200de1ecb4d5549d50b05e5576d2e4e30d139/rbs/MethodTypeToParserNode.cc#L424-L440
This commit ensures we properly process trailing type aliases comments
when walking the body of a node. For example:

```rb
module Foo
  BAR = 123
  #: type bar = Integer
end
```

It extracts a helper method to avoid duplicating the logic for processing
trailing comments.

It also fixes the same issue when the body of the node is empty:

```rb
module Foo
  #: type bar = Integer
end
```

This case was not previously handled in the original RBS rewriter
either. As such, I fixed it there too, also pulling our a helper method
to avoid duplicating the logic.
This commit ensures we properly process trailing type aliases comments
when walking the body of a node. For example:

```rb
module Foo
  BAR = 123
  #: type bar = Integer
end
```

It extracts a helper method to avoid duplicating the logic for
processing trailing comments.
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.

4 participants