Issue #8088 has been updated by yorickpeterse (Yorick Peterse).


As a follow up, a while ago I resolved a similar issue in Rubinius. Although
Rubinius would provide correct argument types it would consider all local
variables in a method as block arguments. As a result you'd quickly end up with
methods with dozens of parameters while in reaily they only had a few.

At this point Rubinius is the only implementation that I am aware of that
provides accurate results when using UnboundMethod#parameters. It would be
great for the other implementations to also properly address this issue.
----------------------------------------
Feature #8088: Method#parameters (and friends) should provide useful information about core methods
https://bugs.ruby-lang.org/issues/8088#change-40412

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/