rbs icon indicating copy to clipboard operation
rbs copied to clipboard

rbs prototype rbi misses comments for multiline sigs

Open connorshea opened this issue 5 years ago • 0 comments

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

connorshea avatar Mar 15 '20 20:03 connorshea