Skip to content

Commit c59a3b9

Browse files
committed
Fix type check for in operator with any on rhs
1 parent 93ff233 commit c59a3b9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func (v *visitor) BinaryNode(node *ast.BinaryNode) (reflect.Type, info) {
316316
if isAny(l) && anyOf(r, isString, isArray, isMap) {
317317
return boolType, info{}
318318
}
319-
if isAny(l) && isAny(r) {
319+
if isAny(r) {
320320
return boolType, info{}
321321
}
322322

checker/checker_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,3 +777,14 @@ func TestCheck_cast_to_expected_works_with_interface(t *testing.T) {
777777
require.NoError(t, err)
778778
})
779779
}
780+
781+
func TestCheck_operator_in_works_with_interfaces(t *testing.T) {
782+
tree, err := parser.Parse(`'Tom' in names`)
783+
require.NoError(t, err)
784+
785+
config := conf.New(nil)
786+
expr.AllowUndefinedVariables()(config)
787+
788+
_, err = checker.Check(tree, config)
789+
require.NoError(t, err)
790+
}

0 commit comments

Comments
 (0)