Skip Menu |
Report information
Id: 122475
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Tue, 5 Aug 2014 23:27:06 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Subject: [BUG] reduce metaop of hyper metaop only works with two or more elements in Rakudo
Download (untitled) / with headers
text/plain 1.3k
<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 [...]
On Tue, 05 Aug 2014 14:27:17 -0700, masak wrote: Show quoted text
> <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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org