Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Prism::Translation::Parser breaks on numbered block params #2345

Closed
exterm opened this issue Feb 2, 2024 · 2 comments · Fixed by #2346
Closed

Bug: Prism::Translation::Parser breaks on numbered block params #2345

exterm opened this issue Feb 2, 2024 · 2 comments · Fixed by #2346

Comments

@exterm
Copy link
Contributor

exterm commented Feb 2, 2024

Minimal example:

Prism::Translation::Parser.parse("find { _1 }")

fails with "undefined method `parameters' for @ NumberedParametersNode":

/home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser/compiler.rb:1752:in `visit_block': undefined method `parameters' for @ NumberedParametersNode (location: (1,5)-(1,11)) (NoMethodError)
└── maximum: 1
:Prism::NumberedParametersNode

              block.body&.accept(copy_compiler(forwarding: find_forwarding(block.parameters&.parameters))),
                                                                                           ^^^^^^^^^^^^
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser/compiler.rb:244:in `visit_call_node'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/node.rb:2302:in `accept'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/compiler.rb:34:in `block in visit_all'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/compiler.rb:34:in `map'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/compiler.rb:34:in `visit_all'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser/compiler.rb:1465:in `visit_statements_node'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/node.rb:16059:in `accept'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/compiler.rb:29:in `visit'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser/compiler.rb:1289:in `visit_program_node'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/node.rb:14140:in `accept'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser.rb:132:in `build_ast'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/prism-0.20.0/lib/prism/translation/parser.rb:47:in `parse'
	from /home/philip/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/parser-3.2.2.0/lib/parser/base.rb:33:in `parse'

Detected when trying to swap Prism::Translation::Parser in for whitequark's Parser::CurrentRuby in packwerk.

@exterm
Copy link
Contributor Author

exterm commented Feb 2, 2024

cc @kddnewton

@kddnewton
Copy link
Collaborator

Thanks @exterm! Fix is up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants