Skip to content

Commit ec7d615

Browse files
committed
Fix in op checker
1 parent d6e36f6 commit ec7d615

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func (v *visitor) BinaryNode(node *ast.BinaryNode) (reflect.Type, info) {
341341
if l == nil { // It is possible to compare with nil.
342342
return boolType, info{}
343343
}
344-
if !isAny(l) && !isInteger(l) {
344+
if !isAny(l) && !l.AssignableTo(r.Elem()) && !(isInteger(l) && isInteger(r.Elem())) {
345345
return v.error(node, "cannot use %v as type %v in array", l, r.Elem())
346346
}
347347
return boolType, info{}

checker/checker_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ var successTests = []string{
5555
"(Any ? 0 : nil) == 0",
5656
"(Any ? nil : nil) == nil",
5757
"!(Any ? Foo : Foo.Bar).Anything",
58-
"Int in ArrayOfFoo",
59-
"Int not in ArrayOfFoo",
58+
"Int in ArrayOfInt",
59+
"Int not in ArrayOfAny",
60+
"String in ArrayOfAny",
61+
"String in ArrayOfString",
6062
"String in Foo",
6163
"String in MapOfFoo",
6264
"String matches 'ok'",

0 commit comments

Comments
 (0)