Bladeren bron

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.
Qi Xiao 1 jaar geleden
bovenliggende
commit
27f6ab2aa1
2 gewijzigde bestanden met toevoegingen van 0 en 8 verwijderingen
  1. 0 4
      pkg/eval/errs/errs.go
  2. 0 4
      pkg/eval/errs/errs_test.go

+ 0 - 4
pkg/eval/errs/errs.go

@@ -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)

+ 0 - 4
pkg/eval/errs/errs_test.go

@@ -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",