ruby / ruby/rbs

rbs prototype rbi should convert T::Enumerator properly

Open
#276 1 comment 0 reactions 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

In Sorbet, T::Enumerator only has one argument (e.g. T::Enumerator[String]), but in ruby-signature it has 2.

Right now, this is the input

class Foo
  sig { returns(T::Enumerator[String]) }
  def bar; end
end

And this is what rbs prototype rbi outputs:

class Foo
  def bar: () -> Enumerator[String]
end

The rbs above causes this error when parsed:

::Enumerator expects parameters [Elem, Return], but given args [::String] (Ruby::Signature::InvalidTypeApplicationError)

I'm not 100% sure, but I think T::Enumerator[String] should be converted to Enumerator[String, self] in ruby-signature?

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 with the rbs prototype rbi entry point and reproduce the conversion using the T::Enumerator[String] example from the issue. Trace the RBI-to-RBS type conversion and determine the correct two-parameter Enumerator representation. Done means the generated RBS parses successfully and expresses the intended enumerator type.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.