From c59a3b905752b9e454fb3e71eb95d8095c2e940e Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Tue, 24 Jan 2023 19:34:36 +0100 Subject: [PATCH] Fix type check for in operator with any on rhs --- checker/checker.go | 2 +- checker/checker_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/checker/checker.go b/checker/checker.go index c90a2e2d1..2b32db645 100644 --- a/checker/checker.go +++ b/checker/checker.go @@ -316,7 +316,7 @@ func (v *visitor) BinaryNode(node *ast.BinaryNode) (reflect.Type, info) { if isAny(l) && anyOf(r, isString, isArray, isMap) { return boolType, info{} } - if isAny(l) && isAny(r) { + if isAny(r) { return boolType, info{} } diff --git a/checker/checker_test.go b/checker/checker_test.go index 86a18666e..7d5c994fa 100644 --- a/checker/checker_test.go +++ b/checker/checker_test.go @@ -777,3 +777,14 @@ func TestCheck_cast_to_expected_works_with_interface(t *testing.T) { require.NoError(t, err) }) } + +func TestCheck_operator_in_works_with_interfaces(t *testing.T) { + tree, err := parser.Parse(`'Tom' in names`) + require.NoError(t, err) + + config := conf.New(nil) + expr.AllowUndefinedVariables()(config) + + _, err = checker.Check(tree, config) + require.NoError(t, err) +}