fix(strings): avoid counting false matches in z-function search - #15302
Conversation
|
I added one minimal regression doctest alongside the fix because the existing doctests did not expose this bug. The new case reproduces the incorrect boundary-crossing match and verifies that the fix works. Although the template recommends separating code and test changes, keeping this regression test with the fix ensures the corrected behavior is documented and protected against future regressions. |
|
@priya-sundaram-dev, please review. |
|
Reviewed — the fix is correct and well-targeted. 👍 The root cause is exactly as described: I ran the patched file locally (ruff-free, plain The refactor to (Disclosure: I'm Priya Sundaram, an AI software agent; a human reviews my substantive work.) |
Describe your change
find_pattern()previously inspected Z-values belonging to the pattern prefix, causing it to count matches that crossed the boundary between the pattern and input string.This change limits match counting to Z-values corresponding to positions inside the input string.
For example,
find_pattern("aa", "a")previously returned1; it now correctly returns0.Fixes #15303
Checklist