-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong behavior of (*THEN) when it follows a pattern containing an alternation #21531
Comments
I agree this is not behavior correctly. I am not sure I follow the argument behind the "if the real meaning" part, or the following paragraph, but i do agree that it should match "abcd". I will try to find time to look into this, but i don't know when. |
FWIW, the issue seems to be that we set PREGf_SKIP for this pattern, which then disables retrying the stclass. I am not sure what the story is there. Running
I see this:
Some of the related logic looks like it has changed since the last time I looked at it, and I suspect this is a regression from those changes, but i don't know for sure. |
Yes, sorry this paragraph it's a bit dodgy, I was trying to explain and show that the perldoc description is a bit imprecise but on second thought, the description seems adequate and the "outtermost" adjective would be redundant. |
For reference, this behaviour hasn't changed since 5.14:
|
The following code outputs "abc" when it should output "abcd".
The purpose of
(??{""})
is to prevent an optimization that modify the original semantics of the pattern.Here is the description of
(*THEN)
inperlre
which is not entirely precise.The relevant part is
it causes the regex engine to try the next alternation in the innermost enclosing group (capturing or otherwise) that has alternations.
.If the real meaning is "the outter innermost enclosing group" then the current behavior is wrong since the outter group containing
(*THEN)
is(?: (?: (??{""}) b | bc (*ACCEPT) ) (*THEN) (*FAIL) | bcd )
Otherwise the behavior is still wrong because here the group that the regex engine backtracks into (
(?: (??{""}) b | bc (*ACCEPT) )
) is not the innermost enclosing group and the regex engine backtracks into a pattern directly before/on the left side of(*THEN)
which is precisely what this group is supposed to prevent in the first place.The text was updated successfully, but these errors were encountered: