# New Ticket Created by  Bruce Gray 
# Please include the string:  [perl #125265]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=125265 >


I tried to translated Perl 5:
   my %bases=('K' => $base, 'M' => $base**2, 'G'=>$base**3, 'T'=>$base**4);
into both of these in Perl 6:
   my %bases = <K M G T> Z=> ( $base  X**   1..* );
   my %bases = <K M G T> Z=> ( $base <<**<< 1..* );

The cross-op version works.
The hyper-op version gives incorrect output:
   <Util> m: my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< 1..* ); 
say %bases.perl
   <camelia> rakudo-moar c2a57e: OUTPUT«{:G(12), :K(10), :M(11), :T(13)}<>␤»

Removing the interactions of Z=> and Whatever, lead to this simplified bug:

< Util> m: say [ 10 <<**<< (1,2,3,4) ].perl;
<+camelia> rakudo-moar c2a57e: OUTPUT«[10, 100, 1000, 10000]␤»
< Util> m: say [ 10 <<**<< (1..4) ].perl;
<+camelia> rakudo-moar c2a57e: OUTPUT«Cannot find method 'Range'␤  in block 
<unit> at /tmp/nk6UBshobl:1␤␤»
< Util> ??? Bug?
< masak> Util: looks like.
< lizmat> repeatable WAT's should be perlbugged  :-)
< masak> Util: please submit.
< Util> lizmat: Noted. masak: will do.
< Util> lizmat: I confess that when I post 2 (working,then non-working) `m:` on 
this channel, and ask `bug?`
< Util> I am also secretly asking "is this a *known* bug, that I would already 
know if I read the channel as much as I should" :^)
< Util> thanks all!
< lizmat> Util: fwiw, it didn't look familiar to me


Note that the problem persists when `**` is changed to `*`.
The result does change when the range is wrapped in parens.

<Util> m: say [ 10 <<*<< (1,2,3,4) ].perl;
<camelia> rakudo-moar c2a57e: OUTPUT«[10, 20, 30, 40]␤»
<Util> m: say [ 10 <<*<< 1..4 ].perl;
<camelia> rakudo-moar c2a57e: OUTPUT«[]␤»
<Util> m: say [ 10 <<*<< (1..4) ].perl;
<camelia> rakudo-moar c2a57e: OUTPUT«Cannot find method 'Range'␤  in block 
<unit> at /tmp/NvWvYfUj6y:1␤␤»

Finally, I do not see the problem when the "magic" pointy-side of the hyper is 
a range;
the problem only shows up on the non-magic side.
<Util> m: say (1,2,3,4) >>*>> (2..3);
<camelia> rakudo-moar c2a57e: OUTPUT«2 6 6 12␤»

-- 
Thank you,
Bruce Gray (Util of PerlMonks)

Reply via email to