ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree
https://ruby-syntax-tree.github.io/syntax_tree/
MIT License
556 stars 54 forks source link

Issue with Ruby 3.1.5 #455

Open rdimartino opened 2 months ago

rdimartino commented 2 months ago

I noticed this from the test failures on this PR

There's different behavior between Ruby 3.1.4 and 3.1.5

Ruby 3.1.4

❯ rbenv shell 3.1.4
❯ bundle exec stree format -e 'foo::x = 1'
foo.x = 1
❯ bundle exec stree ast -e 'foo::x = 1'
(program (statements ((assign (field (vcall (ident "foo")) :"::" (ident "x")) (int "1")))))

Ruby 3.1.5

❯ rbenv shell 3.1.5
❯ bundle exec stree format -e 'foo::x = 1'
undefined method `comments' for 73:Integer

      operator == :"::" ? [] : operator.comments
                                       ^^^^^^^^^
❯ bundle exec stree ast -e 'foo::x = 1'   
(program (statements ((assign (field (vcall (ident "foo")) 73 (ident "x")) (int "1")))))
kddnewton commented 2 months ago

Thank you!

kddnewton commented 2 months ago

Reported here: https://bugs.ruby-lang.org/issues/20449. Looks like this is a bug in the Ruby 3.1.5 backport. I'll put a workaround in here.

rdimartino commented 2 months ago

Great, thanks! I found the offending commit and submitted a patch https://github.com/ruby/ruby/pull/10610

I've never used the Ruby bug tracker before. Is there something that I should do there too?

kddnewton commented 2 months ago

Yeah if you want to comment on the redmine ticket if you want with the PR but I can do it as well if you don't want to make an account.