Bug #3782
closedmatches('k123', '(^|:)?(\d)') returns false
0%
Description
The expression
matches('k123', '(^|:)?(\d)')
returns false.
Reported by Nico Kutscherauer @nkutsche on Twitter.
Updated by Michael Kay over 6 years ago
The issue seems to be that (^|:)?
is being optimized to (^|:)
because matchesEmptyString()
is true. I think we've hit something like this before -- we want to know that a zero-length match is possible, but we don't want to assume that the expression matches EVERY zero-length string.
Updated by Michael Kay over 6 years ago
- Status changed from New to In Progress
- Applies to branch 9.8, trunk added
- Fix Committed on Branch trunk added
I have fixed this on the development branch by refining the method matchesEmptyString() to return a set of values indicating whether a regex (subexpression) matches a zero-length string occurring at the start, at the end, or anywhere, and doing this optimization only if it matches a ZLS anywhere.
As the changes are somewhat extensive and therefore have a relatively high risk of causing regression I'm going to hold back from applying the change on the 9.8 branch, at least for now.
Added QT3 test case fn-matches-54 (which 9.8 is currently failing)
Note: bug 3712 is related, in that it's a similar flaw in the optimization logic.
Updated by Michael Kay over 6 years ago
- Status changed from In Progress to Won't fix
Marking as "won't fix" as the best way of indicating that we are leaving it unresolved on the 9.8 branch.
Please register to edit this issue