# New Ticket Created by Moritz Lenz
# Please include the string: [perl #63976]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=63976 >
Rakudo f8b6aeec564dfa79162b3f6b53302afdc2f33b19:
'8' ~~ /\d (A)*/;
my $x = $/;
for @($x) {
say $_.text;
say "FAIL";
}
# OUTPUT:
8
FAIL
Here (A) never matches, but still @() returns a non-empty list, where
the one item is identical to $/.
Note that in this case the error goes away if we omit the assignment to
a temporary variable, but there are other cases where the error appears
without any explicit assignment being used:
grammar Math {
token TOP { ^ <expr> $ {*} };
token expr {
\d ( A )* {*}
}
}
Math.parse('8');
for @($/<expr>[0]) {
say "FAIL";
}
Some more thinking:
00:46 < moritz_> I think I've got an idea what's going on
00:46 < moritz_> @($stuff) seems to call $stuff.list
00:46 < moritz_> and there seems to be an instance where $stuff is not a
Match object, so it'll return itself
00:47 < moritz_> something like one proxying step that should proxy the
.list method, but doesn't
00:47 < moritz_> rakudo: grammar A { token TOP { ^ <a> $ }; rule a { \d
( A )* {*} }}; A.parse('2'); my $m = $<a>; say $m.PARROT
00:48 < p6eval> rakudo f8b6ae: OUTPUT«Perl6Scalar->A»
00:48 < moritz_> rakudo: grammar A { token TOP { ^ <a> $ }; rule a { \d
( A )* {*} }}; A.parse('2'); say $/.PARROT
00:48 < p6eval> rakudo f8b6ae: OUTPUT«A»