on master help sign in
fix missing atomtype validation in AttributeAtomExpr

resolves #153

commitb1b63110faad8337a51e2414f42368ba38484198 authorAgentM <agentm@themactionfaction.com> dateSat 23 Sep 2017, 10:28 (9 years ago) parent1ec1119
2 files changed+11−3
src/lib/ProjectM36/RelationalExpression.hs+1−1 test/TutorialD/Interpreter.hs+10−2
src/lib/ProjectM36/RelationalExpression.hs+1−1
@@ -808,7 +808,7 @@ verifyAtomExprTypes :: Relation -> AtomExpr -> AtomType -> RelationalExprState (
808808verifyAtomExprTypes relIn (AttributeAtomExpr attrName) expectedType = runExceptT $ do
809809 rstate <- lift ask
810810 case A.atomTypeForAttributeName attrName (attributes relIn) of
811− Right aType -> pure aType
811+ Right aType -> either throwE pure (atomTypeVerify expectedType aType)
812812 (Left err@(NoSuchAttributeNamesError _)) -> case rstate of
813813 RelationalExprStateTupleElems _ _ -> throwE err
814814 RelationalExprStateElems _ -> throwE err
test/TutorialD/Interpreter.hs+10−2
@@ -54,7 +54,8 @@ main = do
5454 testFunctionalDependencies,
5555 testEmptyCommits,
5656 testIntervalAtom,
57− testListConstructedAtom
57+ testListConstructedAtom,
58+ testTypeChecker
5859 ]
5960 simpleRelTests = [("x:=true", Right relationTrue),
6061 ("x:=false", Right relationFalse),
@@ -478,4 +479,11 @@ testListConstructedAtom = TestCase $ do
478479 let err1 = "ConstructedAtomArgumentCountMismatchError 2 1"
479480 expectTutorialDErr sessionId dbconn (T.isPrefixOf err1) "z:=relation{tuple{l Cons 4}}"
480481 let err2 = "TypeConstructorAtomTypeMismatch \"List\" IntegerAtomType"
481− expectTutorialDErr sessionId dbconn (T.isPrefixOf err2) "z:=relation{tuple{l Cons 4 5}}"
482+ expectTutorialDErr sessionId dbconn (T.isPrefixOf err2) "z:=relation{tuple{l Cons 4 5}}"
483+
484+testTypeChecker :: Test
485+testTypeChecker = TestCase $ do
486+ (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
487+ let err1 = "AtomFunctionTypeError \"max\" 1 (RelationAtomType [Attribute \"_\" IntegerAtomType]) IntegerAtomType"
488+ expectTutorialDErr sessionId dbconn (T.isPrefixOf err1) "x:=relation{tuple{a 0}}:{b:=max(@a)}"
489+