From 27f6ab2aa168dde06e85a94026493ba82465fb23 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Sat, 19 Nov 2022 22:29:22 +0000 Subject: [PATCH] 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. --- pkg/eval/errs/errs.go | 4 ---- pkg/eval/errs/errs_test.go | 4 ---- 2 files changed, 8 deletions(-) diff --git a/pkg/eval/errs/errs.go b/pkg/eval/errs/errs.go index ab56828e..dbbf27b7 100644 --- a/pkg/eval/errs/errs.go +++ b/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) diff --git a/pkg/eval/errs/errs_test.go b/pkg/eval/errs/errs_test.go index 912576e3..255f399d 100644 --- a/pkg/eval/errs/errs_test.go +++ b/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",