在我包装子之后,签名不接受包装前接受的捕获。
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)));
}
可能这是一个错误?或者我如何解决该行为,如果这是预期的,我如何在运行时理解我在具体情况下做了解决方法?
最佳答案
Probably it is a bug?
之前我将某些东西称为错误时我错了,但我会说其中存在错误,即使它只是一个 Less Than Awesome 错误消息错误。
我想
wrap
比较少roast tests (许多匹配是误报;在结果中搜索 wrap(
或 wrap:
)。如果您想使用 wrap,这里要做的一件关键事情是添加一个烘焙测试,涵盖我们希望它在此处执行的操作不正确(假设它不仅仅是一个 Less Than Awesome 错误消息)。我认为 wrap 是最脆弱的官方 P6 功能之一:
关于raku - .wrap sub 后签名错误。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52989863/