From 8ecf19df8eac9b6552808ea7b12df67b39162488 Mon Sep 17 00:00:00 2001 From: TristonianJones Date: Thu, 6 Apr 2023 16:23:41 -0700 Subject: [PATCH 1/2] Fix for type guard on optimized set membership step --- interpreter/interpretable.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interpreter/interpretable.go b/interpreter/interpretable.go index 84077917..eedf67d7 100644 --- a/interpreter/interpretable.go +++ b/interpreter/interpretable.go @@ -802,6 +802,9 @@ func (e *evalSetMembership) ID() int64 { // Eval implements the Interpretable interface method. func (e *evalSetMembership) Eval(ctx Activation) ref.Val { val := e.arg.Eval(ctx) + if types.IsUnknownOrError(val) { + return val + } if ret, found := e.valueSet[val]; found { return ret } From beee0737b03fb23f7a97021d218d660f0c5f0500 Mon Sep 17 00:00:00 2001 From: TristonianJones Date: Thu, 6 Apr 2023 16:42:31 -0700 Subject: [PATCH 2/2] Test case for bad logic on optimized set membership tests --- interpreter/interpreter_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interpreter/interpreter_test.go b/interpreter/interpreter_test.go index a2418229..91de37b5 100644 --- a/interpreter/interpreter_test.go +++ b/interpreter/interpreter_test.go @@ -1395,6 +1395,11 @@ var ( unchecked: true, err: `cannot initialize optional list element from non-optional value 123`, }, + { + name: "bad_argument_in_optimized_list", + expr: `1/0 in [1, 2, 3]`, + err: `division by zero`, + }, } )