From: "headius (Charles Nutter)" Date: 2012-09-09T00:25:50+09:00 Subject: [ruby-core:47456] [ruby-trunk - Bug #6994] yield plus splat unwraps too much Issue #6994 has been updated by headius (Charles Nutter). What you're saying makes some sense if we treat all multiple-argument blocks as having an implicit () around them, since that makes method argument behavior match: system ~ $ ruby-1.9.3 -e "def foo; yield *[[1]]; end; foo {|a,b| p a}" 1 system ~ $ ruby-1.9.3 -e "def foo((a, b)); p a; end; foo *[[1]]" 1 But this isn't consistent either, since the single-argument form does not spread arrays: system ~/projects/jruby $ ruby-1.9.3 -e "def foo; yield *[[1]]; end; foo {|a| p a}" [1] system ~/projects/jruby $ ruby-1.9.3 -e "def foo((a)); p a; end; foo *[[1]]" 1 So it spreads an incoming array out when there's more than one receiving argument, but does not spread it out when there's only one receiving argument? ---------------------------------------- Bug #6994: yield plus splat unwraps too much https://bugs.ruby-lang.org/issues/6994#change-29217 Author: headius (Charles Nutter) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 2.0.0dev and 1.9.3p253 I don't see how anyone could argue that 1.9.3 and 2.0.0 are correct here: system ~/projects/jruby $ ruby-1.8.7-p358 -e "def foo; yield *[1]; end; foo {|a, b, *c| p [a,b,c]}" [1, nil, []] system ~/projects/jruby $ ruby-1.8.7-p358 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}" [[1], nil, []] system ~/projects/jruby $ ruby-1.8.7-p358 -e "def foo; yield *[[[1]]]; end; foo {|a, b, *c| p [a,b,c]}" [[[1]], nil, []] system ~/projects/jruby $ ruby-1.9.3 -e "def foo; yield *[1]; end; foo {|a, b, *c| p [a,b,c]}" [1, nil, []] system ~/projects/jruby $ ruby-1.9.3 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}" [1, nil, []] system ~/projects/jruby $ ruby-1.9.3 -e "def foo; yield *[[[1]]]; end; foo {|a, b, *c| p [a,b,c]}" [[1], nil, []] system ~/projects/jruby $ ruby-2.0.0 -e "def foo; yield *[1]; end; foo {|a, b, *c| p [a,b,c]}" [1, nil, []] system ~/projects/jruby $ ruby-2.0.0 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}" [1, nil, []] system ~/projects/jruby $ ruby-2.0.0 -e "def foo; yield *[[[1]]]; end; foo {|a, b, *c| p [a,b,c]}" [[1], nil, []] system ~/projects/jruby $ ruby-1.9.3 -v ruby 1.9.3p253 (2012-07-04 revision 36307) [x86_64-darwin11.4.0] system ~/projects/jruby $ ruby-2.0.0 -v ruby 2.0.0dev (2012-08-27 trunk 36833) [x86_64-darwin11.4.0] JRuby behaves like 1.8 in both 1.8 and 1.9 modes. I would feel pretty dirty fixing it, since I think the 1.9.3/2.0.0 behavior is wrong. -- http://bugs.ruby-lang.org/