Correct that this is a bug, but the patch using Data/Escape.pbc is a bit problematic. Data/Escape.pbc is woefully out of date, and also has problems in that it doesn't correctly generate PIR constants for unicode strings, as would be the case with:
proto prefix:<«> { ... } So, the solution is to use the 'escape' method of the CodeString PMC, which is what other parts of PGE and PCT use when they need to generate PIR constant literals from string values (including unicode and binary strings). For reference I've copied the resulting patch below. Problem fixed in r....., many thanks for the report and patch, both of which made it very easy to see what needed to be fixed. Pm =================================================================== --- runtime/parrot/library/PGE/Perl6Grammar.pir (revision 30633) +++ runtime/parrot/library/PGE/Perl6Grammar.pir (working copy) @@ -366,8 +366,7 @@ goto trait_sub trait_arg: if trait == 'parsed' goto trait_sub - arg = concat "'", arg - arg = concat arg, "'" + arg = optable.'escape'(arg) goto trait_arg_done trait_sub: optable.emit(" $P0 = get_hll_global ['%0'], '%1'", namespace, arg) @@ -382,7 +381,8 @@ concat traitlist, arg goto trait_loop trait_end: - optable.emit(" optable.newtok('%0'%1)", name, traitlist) + name = optable.'escape'(name) + optable.emit(" optable.newtok(%0%1)", name, traitlist) .return () .end