Skip to content

Style/ParallelAssignment breaks in combination with splat operator #13505

@gstokkink

Description

@gstokkink

Style/ParallelAssignment breaks for the following valid bit of Ruby code:

a, b, * = [1, 2, 3]

Error: An error occurred while Style/ParallelAssignment cop was inspecting ...


Expected behavior

Would expect it to not crash, just like it doesn't for the following, equivalent, bit of Ruby code:

a, b, = [1, 2, 3]

Actual behavior

rubocop -d --only Style/ParallelAssignment test.rb
For ...: Default configuration from /Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning .../test.rb
An error occurred while Style/ParallelAssignment cop was inspecting .../test.rb:1:0.
undefined method `splat_type?' for nil
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/style/parallel_assignment.rb:64:in `any?'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/style/parallel_assignment.rb:64:in `allowed_lhs?'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/style/parallel_assignment.rb:36:in `on_masgn'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:69:in `on_masgn'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.36.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/team.rb:174:in `investigate_partial'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cop/team.rb:108:in `investigate'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:349:in `block in inspect_file'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:348:in `each'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:348:in `flat_map'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:348:in `inspect_file'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:291:in `block in do_inspection_loop'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'
<internal:kernel>:187:in `loop'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:318:in `iterate_until_no_changes'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:287:in `do_inspection_loop'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:168:in `block in file_offenses'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:193:in `file_offense_cache'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:167:in `file_offenses'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:158:in `process_file'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:139:in `block in each_inspected_file'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:138:in `each'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:138:in `reduce'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:138:in `each_inspected_file'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:124:in `inspect_files'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/runner.rb:77:in `run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli.rb:122:in `run_command'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli.rb:129:in `execute_runners'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli.rb:51:in `block in run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli.rb:81:in `profile_if_needed'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/lib/rubocop/cli.rb:43:in `run'
/Users/work/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rubocop-1.69.0/exe/rubocop:19:in `<top (required)>'
/Users/work/.rbenv/versions/3.3.6/bin/rubocop:25:in `load'
/Users/work/.rbenv/versions/3.3.6/bin/rubocop:25:in `<main>'

Steps to reproduce the problem

Save the following Ruby code as test.rb:

a, b, * = [1, 2, 3]

Then run rubocop -d --only Style/ParallelAssignment test.rb.

RuboCop version

1.69.0 (using Parser 3.3.6.0, rubocop-ast 1.36.1, analyzing as Ruby 2.7, running on ruby 3.3.6) [arm64-darwin23]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy