Passing an array of parameters to block.call fails for blocks generated from
methods
------------------------------------------------------------------------------------
Key: JRUBY-3295
URL: http://jira.codehaus.org/browse/JRUBY-3295
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1.6, JRuby 1.1.7
Environment: Mac OS X 10.5.6; Java 1.5.0_16;
Reporter: Ryan Phelps
Priority: Minor
I first discovered this when I noticed that the following snippet fails in
JRuby (both 1.1.6 and 1.1.7) and succeeds in Ruby 1.8.6:
{noformat}
module Mod
[:Foo, :Bar].each_with_index &(method :const_set)
end
{noformat}
I came up with a little bit more detailed example that I think may be the same
problem:
{noformat}
def foo(x, y)
puts "#{x} and #{y}"
end
def bar(&block)
block.call ["tweedledee", "tweedledum"]
end
bar &(method :foo)
{noformat}
The results from running the second snippet:
{noformat}
$ ruby test.rb
tweedledee and tweedledum
$ jruby test.rb
test.rb:12:in `to_proc': wrong # of arguments(1 for 2) (ArgumentError)
from test.rb:12:in `call'
from test.rb:12:in `bar'
from test.rb:15
{noformat}
The same error occurs when running the first snippet.
Taking away the array brackets avoids the problem, as does using "yield"
instead of a block variable.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email