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

Layout/RescueEnsureAlignment crashes for block results assigned to setter methods on the same line #12324

Closed
gareth opened this issue Oct 30, 2023 · 0 comments · Fixed by #12325
Labels

Comments

@gareth
Copy link
Contributor

gareth commented Oct 30, 2023

The Layout/RescueEnsureAlignment cop fails with the following minimal reproduction:

# frozen_string_literal: true

object.attribute = loop do
  true
  rescue StandardError
    false
end

Running rubocop against this file results in: An error occurred while Layout/RescueEnsureAlignment cop was inspecting [file].

The error only occurs with a setter method. It doesn't fail if the block is assigned directly to a variable:

object = loop do
  true
  # [...]

The error only occurs if the block is defined on the same line. This does not fail (with any variation of indentation):

object.attribute =
  loop do
    true
    # [...]

The error occurs with any method being passed a block. I used loop here for a minimal example.

And to be clear, the error does not appear with correctly indented code, even with these failure conditions. This passes with no error:

# frozen_string_literal: true

object.attribute = loop do
  true
rescue StandardError
  false
end

Expected behavior

No exception raised

Actual behavior

An error occurred while Layout/RescueEnsureAlignment cop was inspecting /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb:5:2.
undefined method `name' for #<Parser::Source::Map::Send:0x00000001061cea10 @dot=nil, @selector=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @end=nil, @begin=nil, @expression=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @node=s(:send, nil, :object)>
Console output from `bundle exec rubocop -d`
For /Users/gareth/experiments/ruby/rubocop-error: configuration from /Users/gareth/experiments/ruby/rubocop-error/.rubocop.yml
Default configuration from /Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/config/default.yml
Use parallel by default.
Running parallel inspection
Loading cache from /Users/gareth/.cache/rubocop_cache/6194683773286656f529ed18e1296ec50d2a357e/6d7a3b621ca1730e04accd938619e4bdab66cfb1/111eafc7a22bf85a50c301cb132946acd9933ce2
An error occurred while Layout/RescueEnsureAlignment cop was inspecting /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb:5:2.
undefined method `name' for #<Parser::Source::Map::Send:0x000000010839c7c8 @dot=nil, @selector=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @end=nil, @begin=nil, @expression=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @node=s(:send, nil, :object)>
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:108:in `alignment_source'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:89:in `format_message'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:67:in `check'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:37:in `on_resbody'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:105:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:69:in `on_resbody'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `block in on_case'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `on_case'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_rescue'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:159:in `block in on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `each_with_index'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/team.rb:98:in `investigate'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:345:in `block in inspect_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `flat_map'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `inspect_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:164:in `block in file_offenses'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:189:in `file_offense_cache'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:163:in `file_offenses'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:99:in `block in warm_cache'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:627:in `call_with_index'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:597:in `process_incoming_jobs'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:577:in `block in worker'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568:in `fork'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568:in `worker'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:559:in `block in create_workers'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `each_with_index'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `create_workers'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:497:in `work_in_processes'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:291:in `map'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:235:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:99:in `warm_cache'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:72:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command.rb:11:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/environment.rb:18:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:118:in `run_command'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:125:in `execute_runners'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:51:in `block in run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:77:in `profile_if_needed'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:43:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/exe/rubocop:19:in `block in <top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/exe/rubocop:19:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/rubocop:25:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/rubocop:25:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492:in `exec'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28:in `start'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.21/exe/bundle:37:in `block in <top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.21/exe/bundle:29:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
An error occurred while Layout/RescueEnsureAlignment cop was inspecting /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb:5:2.
Inspecting 2 files
Scanning /Users/gareth/experiments/ruby/rubocop-error/Gemfile
Loading cache from /Users/gareth/.cache/rubocop_cache/6194683773286656f529ed18e1296ec50d2a357e/6d7a3b621ca1730e04accd938619e4bdab66cfb1/111eafc7a22bf85a50c301cb132946acd9933ce2
.Scanning /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb
undefined method `name' for #<Parser::Source::Map::Send:0x000000010839c818 @dot=nil, @selector=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @end=nil, @begin=nil, @expression=#<Parser::Source::Range /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb 31...37>, @node=s(:send, nil, :object)>
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:108:in `alignment_source'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:89:in `format_message'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:67:in `check'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/layout/rescue_ensure_alignment.rb:37:in `on_resbody'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:105:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:69:in `on_resbody'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `block in on_case'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:140:in `on_case'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_rescue'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:159:in `block in on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `each_with_index'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:156:in `on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:71:in `on_send'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/team.rb:98:in `investigate'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:345:in `block in inspect_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `flat_map'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:344:in `inspect_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:164:in `block in file_offenses'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:189:in `file_offense_cache'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:163:in `file_offenses'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:154:in `process_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `each'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `reduce'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `each_inspected_file'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:120:in `inspect_files'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:73:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/command.rb:11:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli/environment.rb:18:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:118:in `run_command'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:125:in `execute_runners'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:51:in `block in run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:77:in `profile_if_needed'
1 error occurred:
An error occurred while Layout/RescueEnsureAlignment cop was inspecting /Users/gareth/experiments/ruby/rubocop-error/rescue_ensure_alignment.rb:5:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.57.2 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin20]

/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:43:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/exe/rubocop:19:in `block in <top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.57.2/exe/rubocop:19:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/rubocop:25:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/rubocop:25:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:492:in `exec'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/cli.rb:28:in `start'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.21/exe/bundle:37:in `block in <top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/Users/gareth/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.21/exe/bundle:29:in `<top (required)>'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
/Users/gareth/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
.

2 files inspected, no offenses detected
Finished in 0.32875699999567587 seconds

Steps to reproduce the problem

Save the minimal reproduction file in a directory containing a Gemfile with the following contents:

source 'https://rubygems.org'
gem 'rubocop', '~> 1.57'

and a .rubocop.yml file with the following contents

AllCops:
  NewCops: enable

Run bundle install followed by bundle exec rubocop

RuboCop version

$ bundle exec rubocop -V
1.57.2 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin20]
@gareth gareth changed the title Layout/RescueEnsureAlignment crashes for block results assigned to setter methods on the same line Layout/RescueEnsureAlignment crashes for block results assigned to setter methods on the same line Oct 30, 2023
@koic koic added the bug label Oct 30, 2023
koic added a commit to koic/rubocop that referenced this issue Oct 31, 2023
Fixes rubocop#12324.

This PR fixes an error for `Layout/RescueEnsureAlignment`
when using `rescue` in `do`...`end` block assigned to object attribute.
koic added a commit that referenced this issue Oct 31, 2023
…e_alignment

[Fix #12324] Fix an error for `Layout/RescueEnsureAlignment`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants