From 8dcafac16c4a9f1f89922ec27cdc9e0a9dacf144 Mon Sep 17 00:00:00 2001 From: Springcomp Date: Wed, 21 Jun 2023 22:01:24 +0200 Subject: [PATCH] Fixes #69 - evaluate rhs after string slices Signed-off-by: Springcomp --- compliance | 2 +- pkg/interpreter/interpreter.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compliance b/compliance index ffa8a5a..304b287 160000 --- a/compliance +++ b/compliance @@ -1 +1 @@ -Subproject commit ffa8a5ac6eb73c4297ff7d997ac5786ee4309d59 +Subproject commit 304b287a9537673227c2e300a34ff8e4757579c5 diff --git a/pkg/interpreter/interpreter.go b/pkg/interpreter/interpreter.go index 5f15aa0..4d9090c 100644 --- a/pkg/interpreter/interpreter.go +++ b/pkg/interpreter/interpreter.go @@ -374,7 +374,13 @@ func (intr *treeInterpreter) execute(node parsing.ASTNode, value any, functionCa } stringType, ok := left.(string) if allowString && ok { - return stringType, nil + // a projection is really a sub-expression in disguise + // we must evaluate the right hand expression + result, err := intr.Execute(node.Children[1], stringType) + if err != nil { + return nil, err + } + return result, nil } return nil, nil }