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

chaining block with argument crushes rufo #264

Open
sevenc-nanashi opened this issue Jun 29, 2021 · 1 comment
Open

chaining block with argument crushes rufo #264

sevenc-nanashi opened this issue Jun 29, 2021 · 1 comment

Comments

@sevenc-nanashi
Copy link
Collaborator

sevenc-nanashi commented Jun 29, 2021

mymethod "somearg" do |arg|
  puts "ABC"
end.abc do |arg|
  puts "DEF"
end

It crushes rufo with this traceback:

You've found a bug!
It happened while trying to format the file e:\workspace\discorb\__test.rb
Please report it to https://github.com/ruby-formatter/rufo/issues with code that triggers it
C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:1282:in `visit_command_args': undefined method `[]' for nil:NilClass (NoMethodError)
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:1254:in `visit_command_call'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:353:in `visit'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:1349:in `visit_call_with_block'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:368:in `visit'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:526:in `block (2 levels) in visit_exps'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:3695:in `push_node'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:525:in `block in visit_exps'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:504:in `each'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:504:in `each_with_index'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:504:in `visit_exps'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:201:in `visit'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/formatter.rb:177:in `format'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:146:in `format'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:107:in `format_file'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:85:in `block in format_args'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:78:in `each'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:78:in `format_args'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:40:in `run'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/lib/rufo/command.rb:12:in `run'
        from C:/develop/Ruby30/lib/ruby/gems/3.0.0/gems/rufo-0.12.0/exe/rufo:4:in `<top (required)>'
        from C:/develop/Ruby30/bin/rufo:23:in `load'
        from C:/develop/Ruby30/bin/rufo:23:in `<main>'
@sevenc-nanashi
Copy link
Collaborator Author

Note: It won't happen with:

mymethod("somearg") do |arg|
  puts "ABC"
end.abc do |arg|
  puts "DEF"
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant