Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attribute of cloned object becomes Parcel instead of Array and Pair instead of Hash #4388

Closed
p6rt opened this issue Jul 8, 2015 · 5 comments
Labels
JVM Related to Rakudo-JVM

Comments

@p6rt
Copy link

p6rt commented Jul 8, 2015

Migrated from rt.perl.org#125577 (status was 'resolved')

Searchable as RT125577$

@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

From @usev6

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 rakudo/rakudo@7aa070e

There are two tests (fudged 'todo') in S12-attributes/clone.t.

@p6rt
Copy link
Author

p6rt commented Apr 8, 2016

From @peschwa

On Wed Jul 08 12​:43​:43 2015, bartolin@​gmx.de wrote​:

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
rakudo/rakudo@7aa070e

There are two tests (fudged 'todo') in S12-attributes/clone.t.

This was fixed in rakudo commit 0c78181 and the test file now passes on R-J.

@p6rt
Copy link
Author

p6rt commented Apr 8, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 9, 2016

From @usev6

On Fri Apr 08 05​:56​:54 2016, peschwa@​gmail.com wrote​:

This was fixed in rakudo commit 0c78181 and the test file now passes
on R-J.

Thanks a lot! I'm closing this ticket as 'resolved'.

@p6rt p6rt closed this as completed Apr 9, 2016
@p6rt
Copy link
Author

p6rt commented Apr 9, 2016

@usev6 - Status changed from 'open' to 'resolved'

@p6rt p6rt added the JVM Related to Rakudo-JVM label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JVM Related to Rakudo-JVM
Projects
None yet
Development

No branches or pull requests

1 participant