Skip to content

RBS Rewriting doesn't preserve line numbers #787

@gmalette

Description

@gmalette

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions