on master help sign in
handle atom function with no arguments
commitc0dfe20ac6f2475ddbba6b9886b5cf4ffcafa72b authorAgentM <agentm@themactionfaction.com> dateWed 24 Aug 2016, 11:57 (10 years ago) parentd620fd0
1 file changed+4−1
src/lib/ProjectM36/RelationalExpression.hs+4−1
src/lib/ProjectM36/RelationalExpression.hs+4−1
@@ -503,12 +503,15 @@ evalAtomExpr tupIn context (FunctionAtomExpr funcName arguments) = do
503503 let functions = atomFunctions context
504504 func <- atomFunctionForName funcName functions
505505 argTypes <- mapM (typeFromAtomExpr (tupleAttributes tupIn) context) arguments
506− _ <- mapM (uncurry atomTypeVerify) $ init (zip (atomFuncType func) argTypes)
507506 let expectedArgCount = length (atomFuncType func) - 1
508507 actualArgCount = length argTypes
508+ safeInit [_] = []
509+ safeInit [] = [] -- different behavior from normal init
510+ safeInit (_:xs) = safeInit xs
509511 if expectedArgCount /= actualArgCount then
510512 Left (AtomFunctionArgumentCountMismatch expectedArgCount actualArgCount)
511513 else do
514+ _ <- mapM (uncurry atomTypeVerify) $ safeInit (zip (atomFuncType func) argTypes)
512515 evaldArgs <- mapM (evalAtomExpr tupIn context) arguments
513516 pure $ (evalAtomFunction func) evaldArgs
514517evalAtomExpr _ context (RelationAtomExpr relExpr) = do