gpt4 book ai didi

raku - 使用 “Lexical with name ' 时,为什么我得到 “will leave” $x' 不存在于该帧中”?

转载 作者:行者123 更新时间:2023-12-04 04:27:30 26 4
gpt4 key购买 nike

我有以下 Raku 代码:

class Thing {
method close {
say "closed";
}
};

for 1..1000 {
my $x will leave { .close } = Thing.new;
}
运行它,我收到错误:
Lexical with name '$x' does not exist in this frame
in block <unit> at c.raku line 7
有趣的是,这只发生在迭代次数足够多的情况下(500 或 100,我没有收到任何错误消息)。
如果我将循环的主体更改为
my $x = Thing.new;
LEAVE $x.close;
然后一切正常,也没有错误。
这里发生了什么?我是不是误会了 will leave构造? (在我看来,这两个版本应该是等价的。)
编辑:进一步观察 - 多次运行代码时,错误出现不确定性。这表明问题在某种程度上与垃圾收集有关,但我仍然对这里实际发生的事情感到困惑。
我正在使用 Rakudo v2021.03。

最佳答案

这是一个错误。已为它提出问题:https://github.com/rakudo/rakudo/issues/4403
我建议在此期间使用解决方法。

关于raku - 使用 “Lexical with name ' 时,为什么我得到 “will leave” $x' 不存在于该帧中”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67949845/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com