在我包装sub之后,签名不接受包装前接受的捕获。
sub wr(:$a) {say $a};
my $sig-before = &wr.signature;
say $sig-before; # (:$a)
say %(:a(3)) ~~ $sig-before; # True
&wr.wrap(-> |c {callsame(c)});
my $sig-after = &wr.signature;
say $sig-after; # (:$a)
say %(:a(3)) ~~ $sig-after; # False
say %(:a(3)) ~~ $sig-before; # False
say $sig-before.WHICH, ' ', $sig-after.WHICH; # Signature|140466574255752 Signature|140466574255752
say $sig-before eq $sig-after; # True
say %(:a(3)).Capture ~~ $sig-after; # 'Cannot invoke object with invocation handler in this context'
say $sig-after.ACCEPTS(%(:a(3)).Capture); # 'Cannot invoke object with invocation handler in this context'我在Rakudo代码中看到:
multi method ACCEPTS(Signature:D: Capture $topic) {
nqp::p6bool(nqp::p6isbindable(self, nqp::decont($topic)));
}可能是个bug吧?或者,如果这是预期的行为,我如何解决它,以及我如何在运行时理解我在具体情况下已经完成了解决方法?
发布于 2018-10-25 23:49:26
可能是个bug吧?
以前,当我把一些东西称为bug时,我就错了,但我会说里面有bug,即使它只是一个不太棒的错误消息bug。
我认为wrap的roast tests相对较少(许多匹配都是误报;在结果中搜索wrap(或wrap: )。如果你想使用wrap,这里要做的一件关键事情是添加一个roast测试,覆盖我们希望它在这里做的事情,但它没有正确地做(假设它不仅仅是一个不太好的错误消息)。
我认为wrap是P6官方最脆弱的特性之一:
https://stackoverflow.com/questions/52989863
复制相似问题