Skip Menu |
Report information
Id: 123934
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: beasley [at] web.de
Cc:
AdminCc:

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



Subject: backtracking in LTM alternation in ratchet mode fails
Date: Wed, 25 Feb 2015 23:51 +0100
To: rakudobug [...] perl.org
From: <beasley [...] web.de>
Download (untitled) / with headers
text/plain 249b
say "asdfEnd" ~~ /:ratchet [ xyz | .+! ] End /; => Nil I would expect this to match. I also tested (and work as I'd expect): say "asdfEnd" ~~ / [ xyz | .+ ] End /; =>「asdfEnd」 say "asdfEnd" ~~ /:ratchet [ xyz || .+! ] End /; => 「asdfEnd」
Subject: [perl #123934]
Date: Tue, 19 Apr 2016 23:14:54 +0200
To: perl6-bugs-followup [...] perl.org
From: <beasley [...] web.de>
Download (untitled) / with headers
text/plain 250b
As expressed by perlpilot++ and some others, having say "asdfEnd" ~~ /:ratchet [ xyz | .+! ] End /; say "asdfEnd" ~~ /:ratchet [ xyz || .+! ] End /; say "asdfEnd" ~~ /:ratchet [ .+! ] End /; all fail might also be a way to harmonize the behavior.
Date: Sat, 21 May 2016 20:07:45 +0200
From: <beasley [...] web.de>
Subject: [perl #123934]
To: perl6-bugs-followup [...] perl.org
Download (untitled) / with headers
text/plain 336b
(I tried adding this comment about a month ago, but failed hard. Thus another try.) As expressed by perlpilot++ and some others, having say "asdfEnd" ~~ /:ratchet [ xyz | .+! ] End /; say "asdfEnd" ~~ /:ratchet [ xyz || .+! ] End /; say "asdfEnd" ~~ /:ratchet [ .+! ] End /; all fail might also be a way to harmonize the behavior.
Download (untitled) / with headers
text/plain 1.2k
The way I understand it, following S02 strictly should mean the first two should fail, but the third one should match. Think of the regex as an expression made up of nested operations. 1) In the case of /:r [ xyz | .+! ] End/, the last operation before the "End" is an alternation. The :ratchet is supposed to¹ prevent backtracking into alternations, thus this should fail. 2) In the case of /:r [ xyz || .+! ] End/, the same reasoning applies - except if the phrasing¹ in S05 is imprecise and it actually only meant for `|` alternations to be affected by :ratchet but not `||` alternations. 3) In the case of /:r [ .+! ] End /, the last operation before the "End" is the + quantifier. (The brackets are not an operator - they only disambiguate precedence, like parens do in normal Perl 6 code.) But this + operation is un-ratcheted by the ! modifier, so it can be backtracked into if the "End" does not match. So this regex should match. If this interpretation is correct, it would mean that the actual bug is not that the `|` version fails to backtrack, but that the `||` version does backtrack when it shouldn't. --- ¹⁾ See this paragraph <http://design.perl6.org/S05.html#line_621> in S05 which explicitly mentions alternations.


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