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 in Style/ExplicitBlockArgument #8825

Closed
ghiculescu opened this issue Oct 1, 2020 · 1 comment · Fixed by #8826
Closed

Crash in Style/ExplicitBlockArgument #8825

ghiculescu opened this issue Oct 1, 2020 · 1 comment · Fixed by #8826
Labels

Comments

@ghiculescu
Copy link
Contributor

Expected behavior

Style/ExplicitBlockArgument not to crash on the code below.

Actual behavior

Style/ExplicitBlockArgument is crashing on a file that just contains this code:

if @foo
  render "partial", prop: @bar do
    yield
  end
end

Here's the backtrace:

An error occurred while Style/ExplicitBlockArgument cop was inspecting test.rb:3:4.
undefined method `arguments?' for nil:NilClass
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:80:in `add_block_argument'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:66:in `block (2 levels) in on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/base.rb:333:in `correct'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/base.rb:126:in `add_offense'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:60:in `block in on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:57:in `yielding_block?'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/style/explicit_block_argument.rb:57:in `on_yield'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:99:in `block (2 levels) in trigger_responding_cops'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:152:in `with_cop_error_handling'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/rubocop-0.92.0/lib/rubocop/cop/commissioner.rb:98:in `block in trigger_responding_cops'

The actual error came up when running haml_lint. But I think it's a rubocop error, because you can replicate in a ruby file.

For the record, this works fine:

def method
  if @foo
    render("partial", prop: @bar) do
      yield
    end
  end
end

RuboCop version

$ [bundle exec] rubocop -V
0.92.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.7.1 x86_64-darwin19)
@ghiculescu
Copy link
Contributor Author

#8826 should fix this.

@koic koic closed this as completed in #8826 Oct 1, 2020
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