Skip to content

Keyword arguments are catched as arguments instead of keyword arguments #7572

@Goltergaul

Description

@Goltergaul

Having the following test.rb script:

class Foo
  def test(foo:)
    yield(foo: foo + 1)
  end
end

args = []
kwargs = { foo: 10 }
Foo.new.public_send("test", *args, **kwargs) do |*sub_args, **sub_kwargs|
  puts "test"
  puts sub_args.inspect
  puts sub_kwargs.inspect
end

The following happens with jruby 9.4.0.0: as you can see, the keyword argument { foo: 11 } is catched in sub_args instead of sub_kwargs

14:02 $ ruby -v
jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec159f OpenJDK 64-Bit Server VM 11.0.17+8-post-Ubuntu-1ubuntu222.04 on 11.0.17+8-post-Ubuntu-1ubuntu222.04 +jit [x86_64-linux]

14:02 $ ruby test.rb 
test
[{:foo=>11}]
{}

This does not happen on ruby MRI 3.1.2:

14:04 $ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

ruby test.rb 
test
[]
{:foo=>11}
``

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