Fix lint errors

This commit is contained in:
Brian Picciano 2023-10-27 18:57:44 +02:00
parent c2adfa3b46
commit da5d171479
2 changed files with 9 additions and 6 deletions

View File

@ -53,9 +53,7 @@ var (
Rune('-'),
positiveNumber,
func(neg Located[rune], posNum Located[string]) Located[string] {
return Located[string]{
neg.Location, string(neg.Value) + posNum.Value,
}
return Locate(neg.Location, string(neg.Value)+posNum.Value)
},
)
@ -68,7 +66,7 @@ var (
panic(fmt.Errorf("parsing %q as int: %w", str, err))
}
return Located[Value]{str.Location, Number(i)}
return Locate(str.Location, Number(i))
},
)
)
@ -93,7 +91,7 @@ var (
for _, r := range tail {
name = append(name, r.Value)
}
return Located[Value]{head.Location, Name(string(name))}
return Locate(head.Location, Name(string(name)))
},
)
)
@ -228,7 +226,7 @@ var graphSym, value = func() (
gs.g = new(Graph)
}
return Located[Value]{r.Location, Value{Graph: gs.g}}
return Locate(r.Location, Value{Graph: gs.g})
},
)

View File

@ -18,6 +18,11 @@ type Located[T any] struct {
Value T
}
// Locate returns a Located instance combining the given values.
func Locate[T any](l Location, v T) Located[T] {
return Located[T]{l, v}
}
// LocatedError is an error related to a specific point within a stream of
// runes.
type LocatedError Located[error]