@@ -378,12 +378,18 @@ predicateRestrictionFilter context _ (RelationalExprPredicate relExpr) = case ru
378378 else
379379 Left $ PredicateExpressionError "Relational restriction filter must evaluate to 'true' or 'false'"
380380
381−predicateRestrictionFilter context _ (AttributeEqualityPredicate attrName atomexpr) = Right $ \tupleIn -> case atomForAttributeName attrName tupleIn of
382− Left _ -> False
383− Right atomIn ->
384− case evalAtomExpr tupleIn context atomexpr of
381+predicateRestrictionFilter context attrs (AttributeEqualityPredicate attrName atomExpr) = do
382+ attr <- A.attributeForName attrName attrs
383+ atomExprType <- typeFromAtomExpr attrs context atomExpr
384+ if atomExprType /= A.atomType attr then
385+ Left $ TupleAttributeTypeMismatchError (A.attributesFromList [attr])
386+ else
387+ Right $ \tupleIn -> case atomForAttributeName attrName tupleIn of
385388 Left _ -> False
386− Right atomCmp -> atomCmp == atomIn
389+ Right atomIn ->
390+ case evalAtomExpr tupleIn context atomExpr of
391+ Left _ -> False
392+ Right atomCmp -> atomCmp == atomIn
387393
388394-- in the future, it would be useful to do typechecking on the attribute and atom expr filters in advance
389395predicateRestrictionFilter context attrs (AtomExprPredicate atomExpr) = do