seattlerb / ruby_parser

ruby_parser is a ruby parser written in pure ruby. It outputs s-expressions which can be manipulated and converted back to ruby via the ruby2ruby gem.
http://www.zenspider.com/projects/ruby_parser.html
476 stars 100 forks source link

Fix line numbering for right-hand side of multiple assignment #294

Closed mvz closed 5 years ago

mvz commented 5 years ago

Together with #288, supersedes #289.

>> ENV['VERBOSE'] = 'true' #=> "true"
>> RubyParser.for_current_ruby.parse("a, b = c\nd")
# => s(:block,
#      s(:masgn,
#        s(:array, s(:lasgn, :a).line(1), s(:lasgn, :b).line(1)).line(1),
#        s(:to_ary, s(:call, nil, :c).line(1)).line(2)).line(1),
#      s(:call, nil, :d).line(2)).line(1)

Here, s(:to_ary, s(:call, nil, :c)) has line number 2, but it should be 1. This is fixed in two places due to different target Ruby versions.

mvz commented 5 years ago

Merged in e145a7e7380a4a7f75d597120dacaa7f634a91b4, closing.

zenspider commented 5 years ago

I was just checking on this. This has been fixed by the previous big line numbering commit.