Skip to content

Ambiguous logic is broken #5

@bserdar

Description

@bserdar

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions