Project

General

Profile

Actions

Bug #6994

closed

yield plus splat unwraps too much

Added by headius (Charles Nutter) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.0.0dev and 1.9.3p253
Backport:
[ruby-core:47453]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0