Skip to content

chaining block with argument crushes rufo #264

@sevenc-nanashi

Description

@sevenc-nanashi
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>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions