Incorrect argument splatting/array construction passing splatted args through a 
block that yields
-------------------------------------------------------------------------------------------------

                 Key: JRUBY-2801
                 URL: http://jira.codehaus.org/browse/JRUBY-2801
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
            Reporter: Charles Oliver Nutter
             Fix For: JRuby 1.1.3


This doesn't appear to be specific to compiler or interpreter, so it's either 
an issue with blocks in general or something specific to 
Enumerable#each_with_index:

{noformat}
class Proxy
  def initialize(target)
    @target = target
  end
  private
  def method_missing(method, *args)
    if block_given?
      @target.send(method, *args)  { |*block_args| yield(*block_args) }
    else
      @target.send(method, *args)
    end
  end
end

a = [1, 2, 3]
Proxy.new(a).each_with_index {|x,i| puts "#{i}: #{x.inspect}"}
{noformat}

Output on JRuby and Ruby:

{noformat}
~/NetBeansProjects/jruby ➔ jruby test.rb
: [1, 0]
: [2, 1]
: [3, 2]
~/NetBeansProjects/jruby ➔ ruby test.rb
0: 1
1: 2
2: 3
~/NetBeansProjects/jruby ➔ jruby -X-C test.rb
: [1, 0]
: [2, 1]
: [3, 2]
{noformat}

-- 
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


Reply via email to