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


Rakudo r34342 sometimes destroys the original object when running
.clone(). This works:

$ cat right.p6 class A { has $.b; }
my @q = A.new( :b(1) );
my $p = shift @q;
$p.clone( :b($p.b + 1) );
say $p.b;

$ perl6 right.p6
1

But when a while loop is introduced, the original object is changed:

$ cat wrong.p6
class A { has $.b; }
my @q = A.new( :b(1) );
while shift @q -> $p {
    $p.clone( :b($p.b + 1) );
    say $p.b;
}

$ perl6 wrong.p6
2

Reply via email to