mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Fix in op checker
This commit is contained in:
+1
-1
@@ -341,7 +341,7 @@ func (v *visitor) BinaryNode(node *ast.BinaryNode) (reflect.Type, info) {
|
||||
if l == nil { // It is possible to compare with nil.
|
||||
return boolType, info{}
|
||||
}
|
||||
if !isAny(l) && !isInteger(l) {
|
||||
if !isAny(l) && !l.AssignableTo(r.Elem()) && !(isInteger(l) && isInteger(r.Elem())) {
|
||||
return v.error(node, "cannot use %v as type %v in array", l, r.Elem())
|
||||
}
|
||||
return boolType, info{}
|
||||
|
||||
@@ -55,8 +55,10 @@ var successTests = []string{
|
||||
"(Any ? 0 : nil) == 0",
|
||||
"(Any ? nil : nil) == nil",
|
||||
"!(Any ? Foo : Foo.Bar).Anything",
|
||||
"Int in ArrayOfFoo",
|
||||
"Int not in ArrayOfFoo",
|
||||
"Int in ArrayOfInt",
|
||||
"Int not in ArrayOfAny",
|
||||
"String in ArrayOfAny",
|
||||
"String in ArrayOfString",
|
||||
"String in Foo",
|
||||
"String in MapOfFoo",
|
||||
"String matches 'ok'",
|
||||
|
||||
Reference in New Issue
Block a user