From 26a5a3d8b82c93fea244b40d42bd839c78de78e8 Mon Sep 17 00:00:00 2001 From: Adam Korczynski Date: Tue, 23 Jul 2024 22:28:05 +0100 Subject: [PATCH] fix out of range panic Signed-off-by: Adam Korczynski --- pkg/yqlib/lexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/yqlib/lexer.go b/pkg/yqlib/lexer.go index 904ce756..cc6841b3 100644 --- a/pkg/yqlib/lexer.go +++ b/pkg/yqlib/lexer.go @@ -126,7 +126,7 @@ func handleToken(tokens []*token, index int, postProcessedTokens []*token) (toke if tokenIsOpType(currentToken, createMapOpType) { log.Debugf("tokenIsOpType: createMapOpType") // check the previous token is '[', means we are slice, but dont have a first number - if tokens[index-1].TokenType == traverseArrayCollect { + if index > 0 && tokens[index-1].TokenType == traverseArrayCollect { log.Debugf("previous token is : traverseArrayOpType") // need to put the number 0 before this token, as that is implied postProcessedTokens = append(postProcessedTokens, &token{TokenType: operationToken, Operation: createValueOperation(0, "0")})