Arity 2 and a 1-elem list seems to be special-cased; otherwise, it
consistently warns once per undefined value in the expansion:

(1..4).reduce({$^a+$^b+$^c+$^d})    # no warnings
(1..5).reduce({$^a+$^b+$^c+$^d})    # two warnings: (1+2+3+4)+5+undef+undef
(1..6).reduce({$^a+$^b+$^c+$^d})    # one warning:  (1+2+3+4)+5+6+undef
(1..7).reduce({$^a+$^b+$^c+$^d})    # no warnings: (1+2+3+4)+5+6+7
(1..8).reduce({$^a+$^b+$^c+$^d})    # two warnings:
((1+2+3+4)+5+6+7)+8+undef+undef


On Mon, Dec 22, 2008 at 10:11 AM, via RT Carl Mäsak
<perl6-bugs-follo...@perl.org> wrote:
> # New Ticket Created by  "Carl Mäsak"
> # Please include the string:  [perl #61610]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=61610 >
>
>
> <moritz_> rakudo: say (1..10).reduce({$^a + $^b + $^c})
> <p6eval> rakudo 34244: OUTPUT[Use of uninitialized value␤55␤]
> <PerlJam> that's interesting
> * PerlJam is looking at the code now
> <masak> PerlJam: are you also submitting a rakudobug? otherwise I am.
> <PerlJam> go ahead
> * masak submits rakudobug
> <eric256> whats the bug?
> <masak> eric256: the "Use of uninitialized value" warning above.
> <moritz_> masak: maybe that's because it just doesn't work to reduce a
> list of every possible size with a three-arg function?
> <eric256> but it was unitiliazed
> <masak> moritz_: yes, now that I look at it, I think so too.
> <masak> eric256: what was?
> <PerlJam> still a bug though
> <PerlJam> (IMHO)
> <eric256> $^b and $^c for the last run
> <masak> PerlJam: aye, it shouldn't warn, methinks
> <masak> eric256: you're right.
> <PerlJam> yeah, it pushes an appropriate number of undef to fill out
> the arity of the sub.
> <eric256> rakudo: list(1).reduce( { $^a.say; $^b.say;});
> <p6eval> rakudo 34244: RESULT[1]
> <rjh-> how else would you handle it?
> <eric256> ohh but that should have the same error then
> <eric256> rakudo: list(1).reduce( { $^a + $^b;});
> <p6eval> rakudo 34244: RESULT[1]
> <eric256> rakudo: list(1).reduce( { $^a + $^b + $^c;});
> <p6eval> rakudo 34244: RESULT[1]
> <eric256> rakudo: list(1,2).reduce( { $^a + $^b + $^c;});
> <p6eval> rakudo 34244: OUTPUT[Use of uninitialized value␤]
> <eric256> okay thats a bit weird
> <masak> something inconsistent is going on.
>



-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to