Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce metaop of hyper metaop only works with two or more elements in Rakudo #3475

Open
p6rt opened this issue Aug 5, 2014 · 3 comments
Open
Labels
Bug

Comments

@p6rt
Copy link

@p6rt p6rt commented Aug 5, 2014

Migrated from rt.perl.org#122475 (status was 'open')

Searchable as RT122475$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Aug 5, 2014

From @masak

<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 [...]

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented May 10, 2017

From @MasterDuke17

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 rakudo/rakudo@6b3930e.

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 perl6/roast@1244df8

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented May 10, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.