ruby / ruby/rbs

rbs prototype rbi misses comments for multiline sigs

Open
#231 0 comments 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 you can have multiline sigs using do/end blocks, like so:

module Bar
  # This is a method.
  sig do
    params(x: Integer).void
  end
  def self.foo(x); end
end

When you use rbs prototype rbi on this signature to convert it to RBS, the comment doesn't get included in the RBS output:

module Bar
  def self.foo: (Integer x) -> void
end

I wrote a test to show this issue, if you want to use it:

  def test_comment_with_multiline_sig
    parser = RBI.new

    parser.parse <<-EOF
module Bar
  # This is a method.
  sig do
    params(x: Integer).void
  end
  def self.foo(x); end
end
    EOF

    assert_write parser.decls, <<-EOF
module Bar
  # This is a method.
  def self.foo: (Integer x) -> void
end
    EOF
  end

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 provided test, test_comment_with_multiline_sig, and the RBI.new parser setup; run the rbs prototype rbi conversion against the multiline sig example. Trace how the preceding comment is associated with the declaration, then make the test pass while preserving the comment in the RBS output.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.