Method#parameters returning empty array for some Object methods #583

Closed
ryanong opened this Issue Mar 13, 2013 · 1 comment

Projects

None yet

2 participants

@ryanong
ryanong commented Mar 13, 2013
Object.instance_method(:kind_of?).parameters == []

it should equal

[[:req]]
Object.instance_methods.map do |method_name|
  m = Object.instance_method(method_name)
  if m.arity != 0 && m.parameters == []
    method_name
  end
end

using the code above I found these methods to have incorrect parameters

[:initialize_clone, :method, :is_a?, :instance_variable_defined?, :instance_variable_get, :instance_variable_set, :public_method, :instance_of?, :!~, :=~, :initialize_dup, :===, :<=>, :eql?, :kind_of?, :==, :equal?, :!=]
@headius
Member
headius commented Mar 13, 2013

Investigating. It would be nice (and possible) to show actual argument names for core methods, but I'll do something halfway for now.

@headius headius added a commit that closed this issue Mar 13, 2013
@headius headius Implement Method#parameters for native methods.
In MRI, native methods will only present a list of :req for fixed-
arity methods or a single :rest for variable-arity methods. I have
duplicated this in JRuby, though I'd prefer to present the more
correct layout of required and optional args. I have filed a bug
with MRI to improve #parameters in this way:

https://bugs.ruby-lang.org/issues/8088

Fixes #583.
8961e2a
@headius headius closed this in 8961e2a Mar 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment