Skip to content

ArgumentError re-splatting empty keyword arguments #7102

@yaauie

Description

@yaauie

This issue comes from an error in Sinatra 2.2.0 when run on JRuby, due to the use of keyword-arg splatting, but has been reduced to eliminate Sinatra from the equation and merely compares MRI against JRuby.

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc): jruby-9.3.0.0, jruby-9.2.19.0 as built by ruby-build
  • Operating system and platform (e.g. uname -a):
    Darwin limbo.lan 18.7.0 Darwin Kernel Version 18.7.0: Tue Jun 22 19:37:08 PDT 2021; root:xnu-4903.278.70~1/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • Installed or activated gems: none
  • Application/framework version (e.g. Rails, Sinatra) none
  • Environment variables N/A

Expected Behavior

With the following minimal script to represent how successfully on MRI, without any of the Sinatra code:

def mew!
  'MEOW'
end

def mew(*args, **kwargs, &bk)
  mew!(*args, **kwargs, &bk)
end

puts mew

MRI handles the zero-keyword call and routes through to the other method:

╭─{ yaauie@limbo:~/REDACTED }
╰─● (rbenv shell 2.7.2; ruby kwargs-splat.rb)        
MEOW
[success]

Actual Behavior

JRuby raises an ArgumentError about arity mismatch:

╭─{ yaauie@limbo:~/REDACTED }
╰─● (rbenv shell jruby-9.3.0.0; ruby kwargs-splat.rb)
ArgumentError: wrong number of arguments (given 1, expected 0)
    mew! at kwargs-splat.rb:2
     mew at kwargs-splat.rb:7
  <main> at kwargs-splat.rb:10
( rbenv shell jruby-9.3.0.0; ruby kwargs-splat.rb; )  7.84s user 0.44s system 380% cpu 2.176 total
[error: 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions