Skip to content

v0.1.374 — str find/count with start/end slice bounds (PMAT-675)

Choose a tag to compare

@noahgift noahgift released this 15 Jun 15:39
· 64 commits to main since this release
d9d3ce9

Capability / correctness (PMAT-675): s.find(sub, start[, end]) and s.count(sub, start[, end]) now transpile (they were rejected — "expected exactly 1" arg). Python searches within the char-slice s[start:end]: find returns the CHAR index in the original string (or -1); count the number of non-overlapping occurrences within the slice. The codegen (rust + ruchy) char-slices the receiver to a fresh String of the selected chars, applies Python clamping to start/end (negative → +len, then clamp to [0, len]; end defaults to len for the 2-arg form), and keeps the byte→char conversion and result offset correct for non-ASCII. Found by the HUNT-V5 differential hunt; verified vs python3 (negative start, miss, non-ASCII char indexing). 432 e2e fixtures.