JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6550

[1.9] yield yields incorrect args when splatted args passed as 2nd arg to yield

    Details

    • Number of attachments :
      0

      Description

      Executing the following:

      def passes(*args, &block); yield([1,2,3]); end
      def fails(*args, &block); yield([1,2,3], *args); end
      
      passes {|x| p x }
      passes(4) {|x| p x }
      fails {|x| p x }
      fails(4) {|x| p x }
      

      In 1.9.3 and rubinius 1.9, all yields print -> [1,2,3]

      In jruby 1.6.7 and 1.7.0 dev (in 1.9 mode), I get:

      [1, 2, 3]
      [1, 2, 3]
      1
      [1, 2, 3]
      

      As you can see, yield([1,2,3], *args) yields the first argument split up instead of yielding the full array. I noticed this bug while trying to get my test suite jruby 1.9 compatible on bacon: https://github.com/chneukirchen/bacon/blob/master/lib/bacon.rb#L346

      This ticket may be related: http://jira.codehaus.org/browse/JRUBY-6499

      Thanks

        Issue Links

          Activity

          Hide
          Charles Oliver Nutter added a comment -

          Confirmed on master as of today.

          Show
          Charles Oliver Nutter added a comment - Confirmed on master as of today.
          Hide
          Charles Oliver Nutter added a comment -

          Results with various JRuby modes, compiled, interpreted, and interpreted with new IR:

          system ~/projects/jruby $ jruby tmp/test.rb 
          [1, 2, 3]
          [1, 2, 3]
          1
          [1, 2, 3]
          
          system ~/projects/jruby $ jruby -X-C tmp/test.rb 
          [1, 2, 3]
          [1, 2, 3]
          1
          [1, 2, 3]
          
          system ~/projects/jruby $ jruby -X-CIR tmp/test.rb 
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          
          Show
          Charles Oliver Nutter added a comment - Results with various JRuby modes, compiled, interpreted, and interpreted with new IR: system ~/projects/jruby $ jruby tmp/test.rb [1, 2, 3] [1, 2, 3] 1 [1, 2, 3] system ~/projects/jruby $ jruby -X-C tmp/test.rb [1, 2, 3] [1, 2, 3] 1 [1, 2, 3] system ~/projects/jruby $ jruby -X-CIR tmp/test.rb [1, 2, 3] [1, 2, 3] [1, 2, 3] [1, 2, 3]
          Hide
          Charles Oliver Nutter added a comment -

          Ok, I guess this got fixed at some point recently. I'm not complaining.

          system ~/projects/jruby $ jruby -X-C tmp/test.rb 
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          
          system ~/projects/jruby $ jruby -X+C tmp/test.rb 
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          [1, 2, 3]
          
          Show
          Charles Oliver Nutter added a comment - Ok, I guess this got fixed at some point recently. I'm not complaining. system ~/projects/jruby $ jruby -X-C tmp/test.rb [1, 2, 3] [1, 2, 3] [1, 2, 3] [1, 2, 3] system ~/projects/jruby $ jruby -X+C tmp/test.rb [1, 2, 3] [1, 2, 3] [1, 2, 3] [1, 2, 3]

            People

            • Assignee:
              Charles Oliver Nutter
              Reporter:
              Gabriel Horner
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: