Skip to content

Commit

Permalink
Fix type check for in operator with any on rhs
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jan 24, 2023
1 parent 93ff233 commit c59a3b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}

Expand Down
11 changes: 11 additions & 0 deletions checker/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit c59a3b9

Please sign in to comment.