From 74ccfea8f6f704c819a641a30ce5ddc8f83f11b4 Mon Sep 17 00:00:00 2001 From: Tristan Swadell Date: Tue, 24 Mar 2020 22:52:02 -0700 Subject: [PATCH] Fix for index attribute resolution via a function call return (#325) --- interpreter/interpreter_test.go | 3 ++- interpreter/planner.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interpreter/interpreter_test.go b/interpreter/interpreter_test.go index bfbf4b42..52d24da8 100644 --- a/interpreter/interpreter_test.go +++ b/interpreter/interpreter_test.go @@ -217,7 +217,7 @@ var ( }, { name: "index", - expr: `m['key'][1] == 42u && m['null'] == null`, + expr: `m['key'][1] == 42u && m['null'] == null && m[string(0)] == 10`, env: []*exprpb.Decl{ decls.NewIdent("m", decls.NewMapType(decls.String, decls.Dyn), nil), }, @@ -225,6 +225,7 @@ var ( "m": map[string]interface{}{ "key": []uint{21, 42}, "null": nil, + "0": 10, }, }, }, diff --git a/interpreter/planner.go b/interpreter/planner.go index 7e80ac80..1af001a2 100644 --- a/interpreter/planner.go +++ b/interpreter/planner.go @@ -501,7 +501,7 @@ func (p *planner) planCallIndex(expr *exprpb.Expr, if isIndAttr { return opAttr.AddQualifier(indAttr.Attr()) } - return nil, fmt.Errorf("unsupported index expression: %v", expr) + return opAttr.AddQualifier(p.attrFactory.RelativeAttribute(ind.ID(), ind)) } // planCreateList generates a list construction Interpretable.