From ff9cf80c66c8cab25c2390b714f114c93d9de5b3 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Wed, 19 Jun 2024 09:24:19 +0200 Subject: [PATCH] operator-index.go: ConstLastIndex is checked --- operator-index.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)