On Tue, 05 Aug 2014 14:27:17 -0700, masak wrote: > <timotimo> m: my @a = $(1, 2, 3); say [>>+<<] @a; > <camelia> rakudo-moar 3ad15f: OUTPUT«Not enough positional parameters > passed; got 1 but expected 2 [...] > <timotimo> m: my @a = $(1, 2, 3), $(0, 0, 0); say [>>+<<] @a; > <camelia> rakudo-moar 3ad15f: OUTPUT«1 2 3» > <timotimo> ^- i don't know how to formulate the bug report for this > <masak> "[BUG] instance of the reduce metaop which should work with > one-element list only works with two or more elements in Rakudo" > <timotimo> perfect > <timotimo> would you do the honors? :) > * masak submits rakudobug > <timotimo> thank you :) > > I think I agree that this is a bug, with the following reasoning: [+] > accepts a list of zero, one, or many elements. The zero and one cases > are special-cased, to be sure, because addition usually involves two > things. But here it essentially means "sum", which can have any number > of things. > > Similarly, [>>+<<] is also a kind of sum: in this case, it is summing > the internal structures of the items in the list (which have to be of > the same shape, because the >> << are pointing inwards). So the >> << > restrict the shape of the items themselves, but not the number of > items. So this kind of sum of one item should work, and just return > that item. > > In that vein, the 0-elem case should also work: > > <masak> m: my @a; say [>>+<<] @a > <camelia> rakudo-moar 3ad15f: OUTPUT«Not enough positional parameters > passed; got 0 but expected 2 [...]
The 1-element case was fixed in https://github.com/rakudo/rakudo/commit/6b3930e92714375a96851b058e6e0d1fd27eae61. The 0-element case doesn't die on rakudo-j, but doesn't return anything at all. [21:25] <MasterDuke_> j: my @a; dd [>>+<<] @a [21:25] <+camelia> rakudo-jvm fb4f16: ( no output ) [21:26] <MasterDuke_> m: my @a; dd [>>+<<] @a [21:26] <+camelia> rakudo-moar 643593: OUTPUT: «Too few positionals passed; expected 2 arguments but got 0 in block <unit> at <tmp> line 1» Tests added in https://github.com/perl6/roast/commit/1244df8c4a