raku - .wrap sub 后签名错误。

标签 raku

在我包装子之后,签名不接受包装前接受的捕获。

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 功能之一:
  • new/open/stalled bugs in RT Perl 6 queue matching 'wrap' .
  • new/open/stalled bugs in RT Perl 6 queue matching 'Cannot invoke object with invocation handler in this context' .
  • open rakudo repo issues matching 'wrap' .
  • open rakudo repo issues matching 'Cannot invoke object with invocation handler in this context' .
  • 关于raku - .wrap sub 后签名错误。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52989863/

    相关文章:

    arrays - perl6 数组赋值 : pointer or copy?

    raku - 无用的哈希 Composer ,或者不能修改不可变的哈希?

    unit-testing - 在 Raku 中进行单元测试时如何模拟类方法

    compiler-errors - "Two terms in a row"错误

    raku - 如何将类方法作为参数传递给perl 6中类的另一个方法

    regex - perl6 正则表达式 : match all punctuations except . 和“

    raku - Perl 6中与Python中的星号表达式等效的功能是什么?

    raku - 我可以转发声明稍后定义的 Perl 6 类吗?

    object - Perl 6 - 是否可以创 build 置元属性的属性特征?

    raku - Perl 6 是否对将使用的顺序交替做出任何 promise ?