Skip to content

Remember the furthest failure when backtracking - #19

Merged
mkantor merged 1 commit into
mainfrom
furthest-failure
Sep 1, 2026
Merged

mkantor merged 1 commit into
mainfrom
furthest-failure

Conversation

@mkantor

@mkantor mkantor commented Aug 31, 2026

Copy link
Copy Markdown
Owner

oneOf already reported the furthest of its alternatives' failures, but failures were not kept across successful parses, so deeper problems were obscured whenever a shorter alternative succeeded in oneOf, even if the parse ultimately failed in an outer parser.

In practice this meant reported error positions/messages were often far removed from the actual mistake, and any parse that stopped early would unhelpfully report "excess content followed valid input".

Success now has a furthestFailure property whose value is what ultimately gets reported by combinators like lookaheadNot and butNot, as well as by parse itself.

This may be a breaking change if you have hand-written parsers.

`oneOf` already reported the furthest of its alternatives' failures,
but failures were not kept across successful parses, so deeper problems
were obscured whenever a shorter alternative succeeded in `oneOf`, even
if the parse ultimately failed in an outer parser.

In practice this meant reported error positions/messages were often far
removed from the actual mistake, and any parse that stopped early would
unhelpfully report "excess content followed valid input".

`Success` now has a `furthestFailure` property whose value is what
ultimately gets reported by combinators like `lookaheadNot` and `butNot`,
as well as by `parse` itself.

This may be a breaking change if you have hand-written parsers.
@mkantor
mkantor merged commit 116c71e into main Sep 1, 2026
1 check passed
@mkantor
mkantor deleted the furthest-failure branch September 1, 2026 02:18
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.

1 participant