pkg/eval/errs: Fix misleading message in OutOfRange.Error.

The method returns a message saying that there is no valid value if ValidHigh <
ValidLow. This was useful when these fields were numbers, but since they are now
strings this no longer works.
This commit is contained in:
Qi Xiao 2022-11-19 22:29:22 +00:00
parent eb1770f2b9
commit 27f6ab2aa1
2 changed files with 0 additions and 8 deletions

View File

@ -18,10 +18,6 @@ type OutOfRange struct {
// Error implements the error interface.
func (e OutOfRange) Error() string {
if e.ValidHigh < e.ValidLow {
return fmt.Sprintf(
"out of range: %v has no valid value, but is %v", e.What, e.Actual)
}
return fmt.Sprintf(
"out of range: %s must be from %s to %s, but is %s",
e.What, e.ValidLow, e.ValidHigh, e.Actual)

View File

@ -12,10 +12,6 @@ var errorMessageTests = []struct {
OutOfRange{What: "list index here", ValidLow: "0", ValidHigh: "2", Actual: "3"},
"out of range: list index here must be from 0 to 2, but is 3",
},
{
OutOfRange{What: "list index here", ValidLow: "1", ValidHigh: "0", Actual: "0"},
"out of range: list index here has no valid value, but is 0",
},
{
BadValue{What: "command", Valid: "callable", Actual: "number"},
"bad value: command must be callable, but is number",