From 95e3693efd559b452ef1cc6735c2e912aad0131b Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 6 Apr 2008 17:59:03 +0000 Subject: [PATCH] Die with a sensible error message if the type of an empty array can't be inferred. --- frontends/OccamTypes.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 9d97ac5..6e47aec 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -867,13 +867,13 @@ inferTypes = applyExplicitM9 doExpression doDimension doSubscript -- If we don't know, assume it's an array. A.Infer -> do taes <- mapM (doArrayElem A.Infer) aes - let elemT = case taes of - -- Empty list -- can't tell what - -- the element type is. - [] -> A.Infer - -- Else use the type of the first - -- element. - ((t, _):_) -> t + elemT <- case taes of + -- Empty list -- can't tell what + -- the element type is. + [] -> dieP m "Cannot infer type of empty array" + -- Else use the type of the first + -- element. + ((t, _):_) -> return t let dims = [makeDimension m (length taes)] return (addDimensions dims elemT, A.ArrayElemArray (map snd taes))