Skip to content

Proposal: Extend ruby-rbs crate features #2954

@dak2

Description

@dak2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions