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


<grondilu> rn: for ^2 { my @b = (^256).roll(64); say :256[@b.shift xx
4] xx @b/4; }
<camelia> ..rakudo-moar 974d00: OUTPUT«1579205690 1355821393
4232504958 2412195070 1054437615 566464174 2486826669 1595923990
991953772 3480634857 424925589 1958990192 3384319984 1422756466
3635660521 4253976283␤===SORRY!===␤Element shifted from empty list␤»
<camelia> ..rakudo-parrot 974d00: OUTPUT«3795212420 3158342417
256165518 1657595798 1786761498 312951935 78079993 1942245667
645834118 4081510027 2310301881 1916196990 4244084058 2864670074
2128534466 370168813␤2347852200 3952915263 1159181934 3552185973
2361045754 3404705198 1276420302 26816…»
<grondilu> « ===SORRY!===␤Element shifted from empty list » was very
much unexpected here.
<masak> m: for ^2 { my @b = 1 xx 4; say (@b.shift xx 2) xx 2 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤===SORRY!===␤Element
shifted from empty list␤»
<masak> that sort of highlights that something is wrong, don't it?
<grondilu> indeed
<masak> m: my @b = 1 xx 4; say (@b.shift xx 2) xx 2
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤»
<masak> huh!
<grondilu> it works in the first iteration, but not in the second.  Go figure.
<masak> grondilu: oh yes, that's it.
* masak submits rakudobug
<masak> m: for ^2 { my @b = 1 xx 4; say @b.shift xx 4 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤1 1 1 1␤»
<TimToady> m: for ^2 { my @b = 1 xx 4; say @b.elems; say (@b.shift xx 2) xx 2 }
<camelia> rakudo-moar 974d00: OUTPUT«4␤1 1 1 1␤4␤===SORRY!===␤Element
shifted from empty list␤»
<TimToady> m: for ^2 { my @b = 1 xx 4; say (@b.shift; @b.shift) xx 2 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1␤1 1␤»
<TimToady> m: for ^2 { my @b = 1 xx 4; say (@b.shift xx 2) for 1..2 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1␤1 1␤===SORRY!===␤Element
shifted from empty list␤»
<TimToady> m: for ^2 { my @b = 1 xx 4; (say "X" xx 2) for 1..2 }
<camelia> rakudo-moar 974d00: OUTPUT«X X␤X X␤X X␤X X␤»
<TimToady> that seems okay
<masak> yes, it's only shifting that somehow gets an old @b or something.
<masak> this seems very much like a lexical bug to me.
* masak shudders
<grondilu> it's weird though, since as TimToady shown, @b is correctly
4 long at the beginning of the second iteration.
<grondilu> m: for ^2 { say my @b = 1 xx 4; (@b.shift xx 2) xx 2 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤1 1 1 1␤»
<grondilu> m: for ^2 { say my @b = 1 xx 4; say (@b.shift xx 2) xx 2 }
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤1 1 1 1␤1 1 1
1␤===SORRY!===␤Element shifted from empty list␤»
<grondilu> oh, it's only when we say it that it gets wrong
<grondilu> m: for ^2 { my @b = 1 xx 4; my @c = (@b.shift xx 2) xx 2; say @c }
<camelia> rakudo-moar 974d00: OUTPUT«1 1 1 1␤===SORRY!===␤Element
shifted from empty list␤»
<grondilu> m: for ^2 { my @b = 1 xx 4; my @c = (@b.shift xx 2) xx 2; }
<camelia> rakudo-moar 974d00: OUTPUT«===SORRY!===␤Element shifted from
empty list␤»
<grondilu> or affects it.
<masak> interesting.
<masak> my bet: something gets the wrong OUTER somewhere when two
nested infix:<xx> are used like that.
<masak> the wrong OUTER points back to the @b from the first
iteration, and so tries to shift an empty array.
<masak> that doesn't explain why we need to observe it for it to
happen, but it explains everything else.

Reply via email to