spoom icon indicating copy to clipboard operation
spoom copied to clipboard

RBS Rewriting doesn't preserve line numbers

Open gmalette opened this issue 4 months ago • 0 comments

Describe the bug

When using Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sig, the line numbers aren't preserved. If the rewritten code is used in lieu of the original source, errors and stacktraces don't line up with the original source.

To Reproduce

print Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs(<<~RB, file: "test.rb")
  # typed: true
 
  #: (
  #| Integer
  #| ) -> void
  def foo(i); end
RB
# typed: true

sig { params(i: Integer).void }
def foo(i); end

foo is defined at line 4 instead of line 6.

Expected behavior

Ideally

# typed: true

sig { params(
  i: Integer
  ).void }
def foo(i); end

But this is fine too

# typed: true

sig { params(i: Integer).void }


def foo(i); end

gmalette avatar Aug 11 '25 16:08 gmalette