Skip to content

Fix StringEq!/StringEqCI! partial matches reporting the wrong failure position - #42

Merged
isc-klu merged 1 commit into
masterfrom
fix/string-eq-partial-match-position
Sep 4, 2026
Merged

Fix StringEq!/StringEqCI! partial matches reporting the wrong failure position#42
isc-klu merged 1 commit into
masterfrom
fix/string-eq-partial-match-position

Conversation

@isc-klu

@isc-klu isc-klu commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Fixes #41

Changes

  • Changed Token::scan_at's Err from String to (usize, String): the position the mismatch actually occurred at, paired with what was expected there.
  • StringEq/StringEqCI's Grammar::scan_at now record the trace at that position instead of their own entry pos, so a partial match into a multi-char literal (e.g. matching - of "->" then failing on >) is attributed to where it actually failed, not the literal's start.

Test Plan

  • Added string_eq_partial_match_records_where_it_actually_failed to tests/error_behavior.rs, asserting both the recorded position and the full Error shape for a partial multi-char match.
  • Ran the full matrix locally: fmt --check, clippy (default / --no-default-features / --all-features), test (all three), doc --all-features.

Notes

… position

Token::scan_at's Err now carries the position the mismatch actually
occurred at (which may be past the entry pos, if a prefix of the chain
matched), not just the expectation string. StringEq/StringEqCI's
Grammar::scan_at use that position when recording the trace instead of
their own entry pos, so a partial match into a multi-char literal (e.g.
matching "-" of "->" then failing on ">") is attributed to where it
actually failed.

Fixes #41
@isc-klu
isc-klu merged commit 6f93ab9 into master Sep 4, 2026
7 checks passed
@isc-klu
isc-klu deleted the fix/string-eq-partial-match-position branch September 4, 2026 17:48
@isc-klu isc-klu mentioned this pull request Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StringEq!/StringEqCI! partial-match failures report the wrong position

1 participant