Parse error in method call caused by a line commented
mildred opened this issue · 2 comments
mildred commented
Using brakeman I had parse errors caused by lines commented out running ruby_parser 3.15.1 on ruby 2.7.2. I could generate a small reproducer:
class TestClass
def test_items
@test_items ||= TestItem
.select_attributes
# .with_paths
.accessible_by_user(@user)
end
end
The error:
$ ruby_parse ./test_ruby_parse.rb
# file = ./test_ruby_parse.rb loc = 10
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/racc-1.5.2/lib/racc/parser.rb:538:in `on_error' #<Racc::ParseError: ./test_ruby_parse.rb:7 :: parse error on value "." (tDOT)> for ./test_ruby_parse.rb
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/racc-1.5.2/lib/racc/parser.rb:538:in `on_error'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser_extras.rb:1304:in `on_error'
(eval):3:in `_racc_do_parse_c'
(eval):3:in `do_parse'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser_extras.rb:1329:in `block in process'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `block in catch'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `catch'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `catch'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:110:in `timeout'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser_extras.rb:1317:in `process'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser.rb:36:in `block in process'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser.rb:33:in `each'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/lib/ruby_parser.rb:33:in `process'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/bin/ruby_parse:50:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/bin/ruby_parse:31:in `each'
/usr/local/rvm/gems/ruby-2.7.2@lcas/gems/ruby_parser-3.15.1/bin/ruby_parse:31:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.7.2@lcas/bin/ruby_parse:23:in `load'
/usr/local/rvm/gems/ruby-2.7.2@lcas/bin/ruby_parse:23:in `<main>'
/usr/local/rvm/gems/ruby-2.7.2@lcas/bin/ruby_executable_hooks:24:in `eval'
/usr/local/rvm/gems/ruby-2.7.2@lcas/bin/ruby_executable_hooks:24:in `<main>'
done
0.01s: 927.64 l/s: 13.77 Kb/s: 0 Kb: 10 loc:./test_ruby_parse.rb
0.01s: 927.64 l/s: 13.77 Kb/s: 0 Kb: 10 loc:TOTAL
zenspider commented
Ah... That's a syntax error in any ruby < 2.7.x... and I haven't done any real 2.7 work yet. Good find. Wanna take a whack at it?
zenspider commented
This is fixed. Release coming soonish.