在语法动作代码中替换怪异的“ p6opaque”错误
我有此操作,该操作覆盖了另一个动作类中的动作:
method taskwiki-prefix($/ is copy) {
my $prefix = $/.Str;
$prefix ~~ s:g!'|'!!;
make $prefix;
}
替换会引发此错误:
,在列表中的类型匹配中没有此类属性'$!
p6opaque:在尝试绑定值
时 评论替代,错误消失了。 dd $ prefix
显示:
str $ prefix =“任务||”
,
所以它只是一个普通的字符串。
如果我删除:g
副词,则不再错误,但是这样做会导致nil
,并且在输出中没有任何内容显示$< task; task; taskwiki-前缀> .made
。
在我看来,如果我猜想,替代和动作中的比赛和动作的比赛发生了一些不良的互动。
有修复吗?
I have this action which overrides an action in another action class:
method taskwiki-prefix($/ is copy) {
my $prefix = $/.Str;
$prefix ~~ s:g!'|'!!;
make $prefix;
}
The substitution throws this error:
P6opaque: no such attribute '$!made' on type Match in a List when trying to bind a value
If I comment out the substitution, the error goes away. dd $prefix
shows:
Str $prefix = " Tasks ||"
So it's just a plain string.
If I remove the :g
adverb, no more error, but doing that makes the made value Nil
and nothing shows up in the output for $<taskwiki-prefix>.made
.
Looks to me like there is some bad interaction going on with the matches in the substitution and the action, if I were to guess.
Any fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
This is another case of your previous question,
替换更新
$/
和:的情况下:g
副词,list
最终以$/和
make
会感到困惑。我提出了改进的错误。:G
,在$/
中有一个Match>
,它已连接到此 - 但是,它不再是<代码>匹配被传递到我建议的方法中的对象:
($/)
,因此对的目标没有混淆制作
。sub
或私有方法
而不是将其放入。This is another case of your previous question, Raku grammar action throwing "Cannot bind attributes in a Nil type object. Did you forget a '.new'?" error when using "make". As there, the
make
function wants to update the$/
currently in scope.Substitutions update
$/
, and::g
adverb, aList
ends up in$/
, andmake
gets confused. I've proposed an improved error.:g
, there is aMatch
in$/
and it is attached to that - however, it's no longer theMatch
object that was passed into the methodI recommend to:
($/)
, so there's no confusion about the target ofmake
.sub
or privatemethod
instead and then call it.通过更改语法以提供更清晰的输出来解决问题,这样我就不必操作
$/
变量。Problem was solved by changing the the grammar to give me a cleaner output so I did not have to manipulate the
$/
variable.