ruby / ruby/rbs

Proposal: Extend `ruby-rbs` crate features

Open
#2,954 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Motivation

The ruby-rbs crate currently provides only the parser layer (AST + Visit trait).
The rbs gem, in contrast, ships several higher-level layers on top of the parser — environment construction, name resolution, and definition (ancestor / method) resolution.

Until those layers exist on the Rust side, downstream tooling (type checkers, LSP servers, code generators) cannot be built using ruby-rbs alone. This issue proposes to gradually port those upper layers into the crate.

Features I want

I'm building a static type checker in Rust for my own gem.
Currently, RBS type definitions are loaded on the Ruby side and the result is then handed over to Rust for analysis.
I'd like to move the loading step into Rust as well, so the whole pipeline can be driven through a Rust interface — which requires the following layers in ruby-rbs:

  • TypeName / Namespace — structured type names like ::Foo::Bar; prerequisite for every layer below
  • EnvironmentLoader — discovering .rbs files from gem paths / libdirs, equivalent to rbs gem's loader
  • Environment — merging declarations from multiple files (class reopens, module aliases) and exposing a lookup API
  • DefinitionBuilder — resolving inherited methods via MRO so callers can ask "what methods does Foo::Bar expose?" without re-implementing ancestor traversal in every consumer

Of course, things won’t always go as planned.

Willingness to contribute

If the RBS core team is planning to expand ruby-rbs with these upper layers, I'd love to contribute actively — not just file this as a wishlist.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing ruby-rbs crate and the corresponding upper layers in the rbs gem. The proposal covers TypeName/Namespace, EnvironmentLoader, Environment, and DefinitionBuilder, so first determine which layer and scope the project will accept. Done would require an agreed Rust interface and implementation plan rather than a single isolated edit.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.