Skip Menu |
Report information
Id: 131187
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: consulting [at] jnthn.net
Cc:
AdminCc:

Severity: (no value)
Tag: regex
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Jonathan Worthington <consulting [...] jnthn.net>
Subject: [REGEX] Regression leading to incorrect capture when an action method is present
To: rakudobug [...] perl.org
Date: Fri, 21 Apr 2017 14:40:30 +0200
This is golfed from a File::Ignore regression. This reproduces it:

grammar Parser {
    token TOP { <matcher>+ }
    proto token matcher { * }
    token matcher:sym<[]> { '[' <( <-[\]]>+ )> ']' }
    token matcher:sym<lit> { <-[/*?[]>+ }
}   
class RuleCompiler {
    # Simply commenting out this causes the matcher:sym<lit> to get the .txt it should. With
    # this, it gets ].txt instead.
    method matcher:sym<[]>($/) { }
}
say Parser.parse('[AB].txt', :actions(RuleCompiler));

Commenting out the action method makes the final match tree correct. Without it, the match tree ends up with the second matcher wrongly capturing the ].

I've had trouble bisecting it due to unbuildable commits; the log is here:


It was fine in 2017.03 and broken in 2017.04, perhaps around the time of the uncurse merge. I'm somewhat suspecting that, since it unified Match and Cursor. This code may be a tricky edge case for the unification since it uses the <( and )> constructs, which make the captured text and the text matched by the cursor differ.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.2k
On Fri, 21 Apr 2017 05:44:48 -0700, consulting@jnthn.net wrote: Show quoted text
> This is golfed from a File::Ignore regression. This reproduces it: > > grammar Parser { > token TOP { <matcher>+ } > proto token matcher { * } > token matcher:sym<[]> { '[' <( <-[\]]>+ )> ']' } > token matcher:sym<lit> { <-[/*?[]>+ } > } > class RuleCompiler { > # Simply commenting out this causes the matcher:sym<lit> to get the > .txt it should. With > # this, it gets ].txt instead. > method matcher:sym<[]>($/) { } > } > say Parser.parse('[AB].txt', :actions(RuleCompiler)); > > Commenting out the action method makes the final match tree correct. > Without it, the match tree ends up with the second matcher wrongly > capturing the ]. > > I've had trouble bisecting it due to unbuildable commits; the log is here: > > https://gist.github.com/Whateverable/119eb26d8ca245bf59ec05bc014c9fc2 > > It was fine in 2017.03 and broken in 2017.04, perhaps around the time of > the uncurse merge. I'm somewhat suspecting that, since it unified Match and > Cursor. This code may be a tricky edge case for the unification since it > uses the <( and )> constructs, which make the captured text and the text > matched by the cursor differ.
Fixed by TimToady++ and test added in S05-metasyntax/angle-brackets.t.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org