Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Keep secondary errors on the last choice even if it fails#949

Merged
zesterer merged 1 commit into
zesterer:mainfrom
tmke8:keep-secondary-in-choice
Jan 22, 2026
Merged

Keep secondary errors on the last choice even if it fails#949
zesterer merged 1 commit into
zesterer:mainfrom
tmke8:keep-secondary-in-choice

Conversation

@tmke8

@tmke8 tmke8 commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Previously, choice() was unnecessarily rewinding (and thus truncating the secondary errors) even on the last choice. This caused secondary errors to be swallowed. If you run the test I added with the main branch, you can see that it only returns one error.

The new behavior I implemented was already the behavior when passing a slice of parsers to choice(). So, this change can be seen as improving the consistency of choice() for tuples vs slices.

@zesterer

Copy link
Copy Markdown
Owner

Very well caught!

I'm extremely surprised that this hadn't been noticed before, although come to think of it, it might explain some subtle edge cases I recall observing a few months ago when messing around with recovery behaviour.

Thanks so much for taking the time to find this!

@zesterer
zesterer merged commit 7d36b51 into zesterer:main Jan 22, 2026
3 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants