From 0bffd42cad5502af0f813e0eac4cff9551f46b4c Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 2 Feb 2009 23:51:37 +0000 Subject: [PATCH] Fixed a missing case (an empty array) in one of the occam passes --- frontends/OccamPasses.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontends/OccamPasses.hs b/frontends/OccamPasses.hs index 1187531..d837d7c 100644 --- a/frontends/OccamPasses.hs +++ b/frontends/OccamPasses.hs @@ -63,7 +63,12 @@ fixConstructorTypes = occamOnlyPass "Fix the types of array constructors" getDims (A.Array ds _) = ds getDims t = error $ "Cannot deduce dimensions of array constructor: " ++ show t + innerType :: A.Type -> A.Type + innerType (A.Array _ t) = t + innerType t = error $ "Cannot deduce dimensions of array constructor: " ++ show t + doExpr :: [A.Dimension] -> [A.Dimension] -> A.Structured A.Expression -> PassM A.Type + doExpr prev (d:_) (A.Several m []) = return $ A.Array (prev ++ [d]) $ innerType prevT doExpr prev (d:dims) (A.Several m ss@(s:_)) = doExpr (prev ++ [d]) dims s doExpr prev _ (A.Only _ e) @@ -73,6 +78,8 @@ fixConstructorTypes = occamOnlyPass "Fix the types of array constructors" = doExpr (prev ++ [count]) (dims) body where count = A.Dimension $ countReplicator rep + doExpr _ dims s = diePC (findMeta s) $ formatCode + ("fixConstructorTypes found unexpected: %, " ++ show s) dims doExpression e = return e