fix objects not comparable to null
This commit is contained in:
parent
f09e6ad09e
commit
504e26dcdd
@ -408,9 +408,14 @@ checkComparisonOperation op expr1' expr2' type1 type2
|
||||
|
||||
checkEqualityOperation :: BinaryOperator -> Expression -> Expression -> DataType -> DataType -> Expression
|
||||
checkEqualityOperation op expr1' expr2' type1 type2
|
||||
| type1 == type2 =
|
||||
| type1 == type2 || (type1 == "null" && isObjectType type2) || (type2 == "null" && isObjectType type1) =
|
||||
TypedExpression "boolean" (BinaryOperation op expr1' expr2')
|
||||
| otherwise = error $ "Equality operation " ++ show op ++ " requires operands of the same type"
|
||||
| type1 /= type2 =
|
||||
error $ "Equality operation " ++ show op ++ " requires operands of the same type. Found types: " ++ type1 ++ " and " ++ type2
|
||||
| (type1 == "null" && not (isObjectType type2)) || (type2 == "null" && not (isObjectType type1)) =
|
||||
error $ "Equality operation " ++ show op ++ " requires that null can only be compared with object types. Found types: " ++ type1 ++ " and " ++ type2
|
||||
| otherwise = error $ "Equality operation " ++ show op ++ " encountered unexpected types: " ++ type1 ++ " and " ++ type2
|
||||
|
||||
|
||||
checkLogicalOperation :: BinaryOperator -> Expression -> Expression -> DataType -> DataType -> Expression
|
||||
checkLogicalOperation op expr1' expr2' type1 type2
|
||||
|
Loading…
Reference in New Issue
Block a user