Skip to content

Style/ArgumentsForwarding with added arguments on Ruby 3.1 results in an error #12109

@herwinw

Description

@herwinw

With the Ruby 3.1 config:

AllCops:
  NewCops: enable
  TargetRubyVersion: 3.1

The following code results in a runtime error:

def foo(**kwargs, &)
  bar(1, **kwargs, &)
end
An error occurred while Style/ArgumentsForwarding cop was inspecting poc.rb:1:0.
undefined method `+' for nil:NilClass

            arg_after_splat = arguments[splat_index + 1]
                                                    ^
vendor/bundle/ruby/3.1.0/gems/rubocop-1.56.0/lib/rubocop/cop/style/arguments_forwarding.rb:336:in `no_post_splat_args?'
[.. more backtrace ...]

RuboCop version

This is a regression in 1.56.0, the same code does not result in crashes in 1.55.1

$ bundle exec rubocop -V
1.56.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.1.2) [x86_64-linux-gnu]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy