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

Ambiguous logic is broken #5

Open
bserdar opened this issue Feb 8, 2022 · 0 comments
Open

Ambiguous logic is broken #5

bserdar opened this issue Feb 8, 2022 · 0 comments
Assignees

Comments

@bserdar
Copy link
Contributor

bserdar commented Feb 8, 2022

units/units.go

Line 47 in 93725cf

for _, unitRegex := range HintedRegex[""] {

If there are no hints, and if more than one regexes match, then it is ambiguous, and you should return the names of both matching regexes. To accommodate, define an error type:

type ErrAmbiguousUnit []string

func (e ErrAmbigousUnit) Error() string {
   return "Ambiguous unit:"+strings.Join([]string(e),", ")
}

and return (string,string,error) from the parse function.

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

No branches or pull requests

2 participants