Issue #8088 has been updated by headius (Charles Nutter).


What do you mean "accurate results when using UnboundMethod#parameters"?

    $ bin/jruby -e "def foo(a, b=1, *c, &d); end; p self.class.instance_method(:foo).parameters"
    [[:req, :a], [:opt, :b], [:rest, :c], [:block, :d]]
    
    $ ruby2.0.0 -e "def foo(a, b=1, *c, &d); end; p self.class.instance_method(:foo).parameters"
    [[:req, :a], [:opt, :b], [:rest, :c], [:block, :d]]
----------------------------------------
Feature #8088: Method#parameters (and friends) should provide useful information about core methods
https://bugs.ruby-lang.org/issues/8088#change-40416

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


I was wiring up #parameters to work for native methods today when I realized MRI doesn't give very good information about variable-arity native methods:

ext-jruby-local ~/projects/jruby $ ruby2.0.0 -e "p ''.method(:gsub).to_proc.parameters"
[[:rest]]

ext-jruby-local ~/projects/jruby $ jruby -e "p ''.method(:gsub).to_proc.parameters"
[[:req], [:opt]]

I think MRI should present the same as JRuby here; gsub is obviously not a rest-arg method and you can't call it with less than 1 or more than 2 arguments. JRuby's presenting the right output here.

I'm probably going to have to change JRuby to do the less-helpful version so we're compliant and tests pass, but I think the specification of #parameters should be that it presents the JRuby version about rather than the MRI version.


-- 
http://bugs.ruby-lang.org/