Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid returning errors when one-or-more groups have no matches #390

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

gordallott
Copy link
Contributor

We had an issue using participle when using a structure like the following

type Union struct {
	Float float64 `( @Float` 
	String string ` | @String+`
    Bool bool     ` | @Boolean )` 
}

The code works as intended, but when you use a @String+ as a part of your union types your error messages get a lot less helpful. Instead of getting errors like

1:1: unexpected token "102"

most of your errors turn into

1:1: sub-expression + must match at least once

This ends up this way because the group node returns an error when @Foo+ doesn't match the minimum quantity which then overrides any other useful error reporting and failthroughs

This small change makes it so that the error is only reported if there is at least one match in a group (and adds a test to enforce it)

@alecthomas
Copy link
Owner

Nice one, thanks!

@alecthomas alecthomas merged commit e31fb00 into alecthomas:master Feb 29, 2024
2 checks passed
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.

2 participants