Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `local_names' in Method#parameters #925

Closed
michaeldv opened this issue May 26, 2011 · 0 comments
Closed

undefined method `local_names' in Method#parameters #925

michaeldv opened this issue May 26, 2011 · 0 comments

Comments

@michaeldv
Copy link

Hi there,

Discovered this while trying to make awesome_print gem work with rbx-head:

$ irb -f
irb> m = [].method(:length)
=> #<Method: Array#length (defined in Array)>
irb> m.parameters
NoMethodError: undefined method `local_names' on an instance of Rubinius::AccessVariable.
   from Kernel(Rubinius::AccessVariable)#local_names (method_missing) at kernel/delta/kernel.rb:79
   from Method#parameters at kernel/common/method.rb:119

It seems that the following fixes the issue (added line 119 in kernel/common/method.rb):

118: def parameters
119:   return [] if Rubinius::AccessVariable === @executable
120:   @executable.local_names.each_with_index.map do |name, i|

However here's more complicated case that involves Rubinius::NativeMethod:

$ irb -f
irb> require "bigdecimal"
=> true
irb> Class Hi
irb> end
=> nil
irb> m = Hi.method(:BigDecimal)
=> #<Method: Class#BigDecimal (defined in Kernel at vm/capi/module.cpp:0)>
irb> m.parameters
NoMethodError: undefined method `local_names' on an instance of Rubinius::NativeMethod.
   from Kernel(Rubinius::NativeMethod)#local_names (method_missing) at kernel/delta/kernel.rb:79
   from Method#parameters at kernel/common/method.rb:119

In theory BigDecimal should show its parameters just like any other method, so returning [] doesn't seem right in this case.

I think the same issue might affect UnboundMethod#parameters. Let me know if you'd like me to dig deeper ;-)

Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants