# New Ticket Created by Christian Bartolomaeus
# Please include the string: [perl #125577]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=125577 >
When passing new values for an attribute '@.fields' as named parameters while
cloning, the cloned object has the value of '@.fields' as a Parcel instead of
an Array:
$ perl6-j -e 'class Foo { has @.fields; }; my $x = Foo.new(:fields<a b>); my
$x2 = $x.clone(:fields<c d>); say $x.fields.WHAT; say $x.fields.perl; say
$x2.fields.WHAT; say $x2.fields.perl'
(Array)
["a", "b"]<>
(Parcel)
$("c", "d")
A similar problem exists for Hash/Pair:
$ perl6-j -e 'my class Foo { has %.h }; my $b1 = Foo.new( h => "a" => "b" ); my
$b2 = $b1.clone( h => "c" => "d" ); say $b1.h.WHAT; say $b1.h.perl; say
$b2.h.WHAT; say $b2.h.perl'
(Hash)
{:a("b")}<>
(Pair)
:c("d")
$ perl6-j --version
This is perl6 version 2015.06-217-g3776723 built on JVM
Moar gets this right. Please note that there is different code for Moar and JVM
-- see commit
https://github.com/rakudo/rakudo/commit/7aa070e046322244e0a17cd071590e03630910b4
There are two tests (fudged 'todo') in S12-attributes/clone.t.