Skip to content

Keyword arguments arity issue #2480

@emboss

Description

@emboss

Probably related to #2320. I get similar results with lambda keyword arguments and keyword arguments passed as a Hash instead of passing them explicitly.

$ jruby -v
jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-18 746583b Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [linux-amd64]
l = lambda  { |a:| a }
l.call(a: 1) # wrong number of arguments (1 for 0)
l.arity # 0 (1 in MRI 2.2.0p0)

After some debugging, I found out that in RubyBlock#prepareArgs the arity is checked on the Signature's arity object (a "Fixed0"), but keyword args would only be considered in Signature#checkArity.

Not sure if this is related or a different issue:

def m(a:, b:); a + b; end
args = { a: 1, b: 2 }
m(args) # ArgumentError: missing keyword: a
method(:m).arity # 0 (1 in MRI 2.2.0p0)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions