Skip to content

Expose a C method to parse type parameters.#44

Merged
Morriar merged 4 commits into
sorbetfrom
at-parse-type-params
May 7, 2025
Merged

Expose a C method to parse type parameters.#44
Morriar merged 4 commits into
sorbetfrom
at-parse-type-params

Conversation

@Morriar
Copy link
Copy Markdown

@Morriar Morriar commented May 1, 2025

This is useful to parse a "class signature" such as this:

#: [in A, B = String, out < Object]
class Foo; end

@Morriar Morriar requested review from amomchilov and st0012 May 1, 2025 20:22
@Morriar Morriar self-assigned this May 1, 2025
@Morriar Morriar force-pushed the at-parse-type-params branch 2 times, most recently from 005a547 to 64cacae Compare May 1, 2025 20:33
Copy link
Copy Markdown
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Not blocking, but do we consider exposing it at Ruby level so we can write tests for it?
I know it's not ideal, but assuming we're going to upstream this later too:

  • Having test cases can help reviewing this API
  • If it's going to be relied on by Sorbet, we should have tests to make sure it's not accidentally broke after upstreaming

Ideally there should be a way to test C-APIs without exposing them directly to RBS's Ruby API. Prism seems to use ffi to expose some functions separately, but it's likely to require a lot to set up.

@Morriar Morriar force-pushed the at-parse-type-params branch from 64cacae to a32ed74 Compare May 6, 2025 15:06
@Morriar Morriar changed the base branch from sorbet to master May 6, 2025 15:06
Morriar added 3 commits May 6, 2025 11:07
This is useful to parse a "class signature" such as this:

```rb
\#: [in A, B = String, out < Object]
class Foo; end
```

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar force-pushed the at-parse-type-params branch from a32ed74 to b5cfd1d Compare May 6, 2025 15:08
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar force-pushed the at-parse-type-params branch from b5cfd1d to fcc18af Compare May 6, 2025 15:08
@Morriar
Copy link
Copy Markdown
Author

Morriar commented May 6, 2025

I exposed the method to Ruby and added a few tests. I hope the Ruby method won't make this too controversial 🤞

@Morriar Morriar changed the base branch from master to sorbet May 6, 2025 20:22
@Morriar Morriar merged commit f8d9d51 into sorbet May 7, 2025
20 checks passed
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.

3 participants