Skip to content

keyword arguments incompatibilities #2512

@blanquer

Description

@blanquer

There are a couple of things that I'm seeing that still don't match the MRI behavior on method keyword arguments.

One is the arity, which returns different results ( but I believe that this might already be tracked in #2480 ?)

The other one is the definition of the keyword types "required" vs. not . For example, required arguments are not reported as such in the .parameters call.

Here's a quick snippet that shows both things, and the difference in results:

class Foo
  def self.test( arg1: "default" , arg2: )
    puts "arg1: #{arg1.inspect}"
  end
end

m = Foo.method(:test)
puts "PARAMS: #{m.parameters.inspect}"
puts "ARITY: #{m.arity}"
bug:~ $ rvm 2.2.0
bug:~ $ ruby /tmp/test.rb
PARAMS: [[:keyreq, :arg2], [:key, :arg1]]
ARITY: 1
bug:~ $ rvm jruby-head
bug:~ $ ruby /tmp/test.rb
PARAMS: [[:key, :arg1], [:key, :arg2]]
ARITY: 0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions