Raku 克隆物体未沉没

cow*_*moo 6 clone sink raku

class A {
  has $.n;

# If this method is uncommented then the clone won't be sunk  
#  method clone {
#    my $clone = callwith(|%_);
#    return $clone;
#  }

  method sink(-->Nil) { say "sinking...$!n" }
}

sub ccc(A:D $a) { $a.clone(n=>2) }

ccc(A.new(n=>1));
say 'Done';
Run Code Online (Sandbox Code Playgroud)

上图:

sinking...2
Done
Run Code Online (Sandbox Code Playgroud)

但是,如果使用自定义clone方法,则返回的克隆 fromccc不会因某种原因沉没。如果我sink明确地在呼叫站点或将my $clone = callwith(|%_)线路更改为my $clone := callwith(|%_). 这是预期的吗?它以这种方式工作的原因是什么?

谢谢!

Eli*_*sen 2

我还不确定发生了什么,但是删除该return语句会使克隆的对象调用正确的sink方法。

我为其创建了一个问题:https ://github.com/rakudo/rakudo/issues/3855