diff --git a/operator-index.go b/operator-index.go index c833a23..af91069 100644 --- a/operator-index.go +++ b/operator-index.go @@ -40,11 +40,14 @@ func verifyRange(indexTerm *term, indexList *ListType, maxValue int) (startIndex v, _ := ((*indexList)[0]).(*intPair) startIndex = v.a endIndex = v.b + if endIndex == ConstLastIndex { + endIndex = maxValue + } if startIndex < 0 && startIndex >= -maxValue { startIndex = maxValue + startIndex } if endIndex < 0 && endIndex >= -maxValue { - endIndex = maxValue + endIndex + 1 + endIndex = maxValue + endIndex } if startIndex < 0 || startIndex > maxValue { err = indexTerm.Errorf("range start-index %d is out of bounds", startIndex)