I've simplified a more complicated pattern I'm trying to match down to the following program:
my token paren { '(' <tok> ')' }
my token tok { <paren>? foo }
say "(foo)foo" ~~ /<tok>/;
This seems straightforward enough to me, but I get this error:
No such method 'tok' for invocant of type 'Match'. Did you mean 'to'?
in regex paren at a.p6 line 1
in regex tok at a.p6 line 2
in block <unit> at a.p6 line 4
What's the reason for this error?
The pattern matches without error if I change the first <tok> to <&tok>, but then I don't get a capture of that named pattern, which, in my original, more-complicated case, I need.