on master help sign in
validate that macro names do not conflict with existing relvars
commit4beffa3e46493e68a678f47fe4f871d94a615eb1 authorAgentM <agentm@themactionfaction.com> dateMon 13 Apr 2020, 00:07 (7 years ago) parent2fbb67a
2 files changed+8−2
src/lib/ProjectM36/RelationalExpression.hs+7−1 test/TutorialD/Interpreter/TestBase.hs+1−1
src/lib/ProjectM36/RelationalExpression.hs+7−1
@@ -1379,8 +1379,14 @@ typeForGraphRefRelationalExpr NotEquals{} = do
13791379typeForGraphRefRelationalExpr (Extend extendTupleExpr expr) = do
13801380 rel <- typeForGraphRefRelationalExpr expr
13811381 evalGraphRefRelationalExpr (Extend extendTupleExpr (ExistingRelation rel))
1382−typeForGraphRefRelationalExpr expr@With{} = do
1382+typeForGraphRefRelationalExpr expr@(With withs _) = do
13831383 let expr' = substituteWithNameMacros [] expr
1384+ checkMacroName (WithNameExpr macroName tid) = do
1385+ rvs <- relationVariables <$> gfDatabaseContextForMarker tid
1386+ case M.lookup macroName rvs of
1387+ Just _ -> lift $ except $ Left (RelVarAlreadyDefinedError macroName) --this error does not include the transaction marker, but should be good enough to identify the cause
1388+ Nothing -> pure ()
1389+ mapM checkMacroName (map fst withs)
13841390 typeForGraphRefRelationalExpr expr'
13851391
13861392evalGraphRefAttributeNames :: GraphRefAttributeNames -> GraphRefRelationalExpr -> GraphRefRelationalExprM (S.Set AttributeName)
test/TutorialD/Interpreter/TestBase.hs+1−1
@@ -49,7 +49,7 @@ expectTutorialDErr sessionId conn matchFunc tutd = case parseTutorialD tutd of
4949 DisplayRelationResult _ -> assertFailure "displayrelation?"
5050 DisplayDataFrameResult _ -> assertFailure "displaydataframe?"
5151 DisplayParseErrorResult _ _ -> assertFailure "displayparseerrorresult?"
52− DisplayErrorResult err -> assertBool ("match error on: " ++ unpack err) (matchFunc err)
52+ DisplayErrorResult err -> assertBool (unpack tutd ++ " match error on: " ++ unpack err) (matchFunc err)
5353 QuietSuccessResult -> pure ()
5454
5555eitherFail :: Either RelationalError a -> IO ()