rubocop / rubocop-ast

RuboCop's AST extensions and NodePattern functionality
https://docs.rubocop.org/rubocop-ast
MIT License
112 stars 53 forks source link

Use Prism 1.1+ #318

Closed koic closed 1 month ago

koic commented 1 month ago

This PR fixes the following build failures when using Prism 1.1+.

$ bundle exec prism_spec
(snip)

Failed examples:

rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:4:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with a single argument and braces
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:1:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with no arguments
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:3:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with a single argument
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:2:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with no arguments and braces
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:6:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with multiple literal arguments
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:2:5:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node #arguments with a single splat argument
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:1:1:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node .new without arguments is expected to be a kind of RuboCop::AST::NextNode
rspec './spec/rubocop/ast/next_node_spec.rb[1:1:1:2:1]'
# RuboCop::AST::NextNode behaves like wrapped arguments node .new with arguments is expected to be a kind of RuboCop::AST::NextNode
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:5:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with a single splat argument
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:6:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with multiple literal arguments
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:1:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with no arguments
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:4:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with a single argument and braces
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:3:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with a single argument
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:2:2:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node #arguments with no arguments and braces
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:1:2:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node .new with arguments is expected to be a kind of RuboCop::AST::BreakNode
rspec './spec/rubocop/ast/break_node_spec.rb[1:1:1:1:1]'
# RuboCop::AST::BreakNode behaves like wrapped arguments node .new without arguments is expected to be a kind of RuboCop::AST::BreakNode

This is due to Prism 1.1 providing the correct behavior equivalent to Ruby's parse.y.

As of Ruby 3.3, using next and break at the top level results in a syntax error. This PR ensures proper validation by enclosing them in blocks for testing.

marcandre commented 1 month ago

Great, thank you 🙏