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


[22:34] <Mouq> m: my @a; (0,1,2).map(-> $k {(2,3,4).map(->$k2
{@a[$k][$k2]})}).eager.Parcel = 4..12; say @a.perl
[22:34] <+camelia> rakudo-moar ffbb70: OUTPUT«Array.new([Any, Any, Any,
Any, 6], [Any, Any, Any, Any, 9], [Any, Any, Any, Any, 12])␤»
[22:34] <Mouq> ^^ Notice, it autovivifies @a's elements, but the assignment
is wrong
[22:34] <Mouq> m: my @a; (0,1,2).map(-> $k {(2,3,4).map(->$k2
{@a[$k][$k2]})}).eager.Parcel = 4..12; (0,1,2).map(-> $k {(2,3,4).map(->$k2
{@a[$k][$k2]})}).eager.Parcel = 4..12; say @a.perl
[22:34] <+camelia> rakudo-moar ffbb70: OUTPUT«Array.new([Any, Any, 4, 5,
6], [Any, Any, 7, 8, 9], [Any, Any, 10, 11, 12])␤»
[22:35] <Mouq> ^^ But doing it twice, it works fine
[22:36] <Mouq> The past few days I've been trying to get LoL assignment to
a) do autoviv and b) do assignment correctly
[22:37] <Mouq> I'm not sure where the above bug comes from, but I'm
guessing it's a bug in Parce.STORE

[22:38] <Mouq> Golfed:
[22:38] <Mouq> m: my @a; (@a[0][1], @a[0][2], @a[1][1], @a[1][2]) =
1,2,3,4; say @a.perl
[22:38] <+camelia> rakudo-moar ffbb70: OUTPUT«Array.new([Any, Any, 2],
[Any, Any, 4])␤»

In fact this can be golfed even further:

perl6 -e'my @a; (@a[0][1], @a[0][2]) = 1,2; say @a.perl'
Array.new([Any, Any, 2])
perl6 -e'my @a; (@a[0][1], @a[0][2]) = 1,2; (@a[0][1], @a[0][2]) = 1,2; say
@a.perl'
Array.new([Any, 1, 2])

The first instance here should have the same output as the second.

Reply via email to