Skip to content

fix: Allow choice fallback after traversal errors - #154

Merged
josevalim merged 1 commit into
dashbitco:masterfrom
mvanhorn:fix/146-post-traverse-choice-fallback
Aug 11, 2026
Merged

fix: Allow choice fallback after traversal errors#154
josevalim merged 1 commit into
dashbitco:masterfrom
mvanhorn:fix/146-post-traverse-choice-fallback

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Update traversal error generation in NimbleParsec.Compiler to honor the active catch_all continuation already carried in compiler configuration, following the failure-routing pattern used by other unbound combinators. post_traverse/3 callbacks may return {:error, reason}, but the compiler currently turns that result directly into the parsec's final error tuple.

A choice/2 whose first branch consumes input and then succeeds in a post-traversal callback returns that branch's transformed result without evaluating the fallback behavior; A post-traversal callback that returns {:error, reason} causes choice/2 to retry a later branch from the original input, producing the fallback result with correct rest, context, position, and byte offset.

Closes #146

@josevalim
josevalim merged commit 5b8bb30 into dashbitco:master Aug 11, 2026
0 of 2 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

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.

post_traverse failure does not fail choice

2 participants