# New Ticket Created by Sam S.
# Please include the string: [perl #129762]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=129762 >
Calling .clone on an Array returns a new Array object, but (even
shallow) changes to one affect the other:
my $a = [2, 4, 6];
my $b = @a.clone;
say $a.WHICH; # Array|68924240
say $b.WHICH; # Array|68924304
@a.push(8);
dd $a; # Array $a = $[2, 4, 6, 8]
dd $b; # Array $b = $[2, 4, 6, 8]
IRC comments:
<jnthn> An Array is an object, with a bunch of attributes, once of
which is the actual storage.
<jnthn> I'm guessing Array doesn't have a method clone of its own,
so it does The Default Thing in Mu
<jnthn> Which keeps the storage
<jnthn> It should probably get its own method clone
<jnthn> I thought that had already happened. :
<jnthn> :S
<jnthn> But yeah, it wants fixing. The current behavior is crap.
<timotimo> cue writing spec tests for .clone of pretty much every
single class :)