seattlerb/ruby_parser

Argument Forwarding without Parenthesis

eric1234 opened this issue · 4 comments

I see in #311 support was added for argument forwarding. I tend to be a minimalist so don't usually put parens on my method defs unless the compiler requires it. This is acceptable by Ruby but not by ruby_parser.

$ irb
irb(main):001:0> require "ruby_parser"
=> true
irb(main):002:0> RubyParserStuff::VERSION
=> "3.20.1"
irb(main):003:1* def foo ...
irb(main):004:0> end
=> :foo
irb(main):005:0" RubyParser.new.parse <<RUBY
irb(main):006:0" def foo(...)
irb(main):007:0" end
irb(main):008:0> RUBY
=> s(:defn, :foo, s(:args, s(:forward_args)), s(:nil))
irb(main):009:0" RubyParser.new.parse <<RUBY
irb(main):010:0" def foo ...
irb(main):011:0" end
irb(main):012:0> RUBY
/home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.2/lib/racc/parser.rb:538:in `on_error': (string):1 :: parse error on value "..." (tDOT3) (Racc::ParseError)                     
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser_extras.rb:1536:in `on_error'
        from (eval):3:in `_racc_do_parse_c'  
        from (eval):3:in `do_parse'          
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser_extras.rb:1560:in `block in process'
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/timeout-0.3.2/lib/timeout.rb:189:in `block in timeout'
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `block in catch'
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
        from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/timeout-0.3.2/lib/timeout.rb:198:in `timeout'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser_extras.rb:1551:in `process'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser.rb:36:in `block in process'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser.rb:33:in `each'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ruby_parser-3.20.1/lib/ruby_parser.rb:33:in `process'
	from (irb):9:in `<main>'
	from /home/me/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/irb-1.6.4/exe/irb:9:in `<top (required)>'
	from /home/me/.asdf/installs/ruby/3.1.0/bin/irb:25:in `load'
	... 1 levels...

good find. wanna take a whack at it?

A: no, no you don't...

I think I have this fixed up.

I apologize for ghosting you. I meant to respond but then got pulled off on some other things and more time than I meant ended up passing.

The answer is still largely the same. Looking over the change you made, my ignorance on Yacc makes this too far outside my wheelhouse. But regardless I should have responded earlier. The work (as well as some of your other work I use) is greatly appreciated.

No worries at all mate. This one was a doozy even for me.