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

Crash on pattern matching in ruby 2.7 #7774

Closed
artofhuman opened this issue Mar 3, 2020 · 1 comment
Closed

Crash on pattern matching in ruby 2.7 #7774

artofhuman opened this issue Mar 3, 2020 · 1 comment
Labels

Comments

@artofhuman
Copy link

artofhuman commented Mar 3, 2020

Crash on pattern matching

Expected behavior

No crash

Actual behavior

`undefined method `type' for nil:NilClass`
Stacktrace
undefined method `type' for nil:NilClass
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `block in on_in_pattern'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `each'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `on_in_pattern'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `block in on_case_match'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `each'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `on_case_match'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:68:in `on_lvasgn'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `block in on_begin'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `each'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:57:in `on_begin'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/ast/traversal.rb:14:in `walk'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/team.rb:124:in `investigate'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/team.rb:112:in `offenses'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cop/team.rb:44:in `inspect_file'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:296:in `inspect_file'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:244:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:269:in `loop'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:269:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:240:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:119:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:143:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:117:in `file_offenses'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:108:in `process_file'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:86:in `each'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:86:in `reduce'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:86:in `each_inspected_file'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:73:in `inspect_files'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/runner.rb:39:in `run'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli/command.rb:10:in `run'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli/environment.rb:17:in `run'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli.rb:65:in `run_command'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli.rb:72:in `execute_runners'
/usr/local/bundle/gems/rubocop-0.80.1/lib/rubocop/cli.rb:41:in `run'
/usr/local/bundle/gems/rubocop-0.80.1/exe/rubocop:13:in `block in <top (required)>'
/usr/local/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/usr/local/bundle/gems/rubocop-0.80.1/exe/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:23:in `load'
/usr/local/bundle/bin/rubocop:23:in `<top (required)>'
/usr/local/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/2.7.0/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/2.7.0/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

Steps to reproduce the problem

result = case 0
in 0 then true
else false
end

puts result

RuboCop version

0.80.1 (using Parser 2.7.0.4, running on ruby 2.7.0 x86_64-linux)
@koic
Copy link
Member

koic commented Mar 11, 2020

This issue will be solved by #7786.

koic added a commit to koic/rubocop that referenced this issue Mar 19, 2020
Closes rubocop#7624 and rubocop#7774.

This PR supports pattern match for `Layout/ElseAlignment` cop.
Also this resolves the crash reported in rubocop#7624 and rubocop#7774 for
using Ruby 2.7's pattern match.
@koic koic closed this as completed Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants