From 439cedb494448253c9582d87770797b2a81b3da0 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Mon, 30 Apr 2007 01:48:30 +0000 Subject: [PATCH] Handle unsubscriptable type contexts --- fco2/Parse.hs | 2 +- fco2/Types.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fco2/Parse.hs b/fco2/Parse.hs index 448a995..635fe1b 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -471,7 +471,7 @@ pushSubscriptTypeContext :: (PSM m, Die m) => m () pushSubscriptTypeContext = do ps <- get case psTypeContext ps of - (Just t):_ -> + (Just t@(A.Array _ _)):_ -> do subT <- trivialSubscriptType t pushTypeContext $ Just subT _ -> pushTypeContext Nothing diff --git a/fco2/Types.hs b/fco2/Types.hs index 4665861..58cb693 100644 --- a/fco2/Types.hs +++ b/fco2/Types.hs @@ -99,7 +99,7 @@ subscriptType (A.SubscriptFor m count) t = sliceType m (makeConstant emptyMeta 0) count t subscriptType (A.SubscriptField m tag) t = typeOfRecordField m t tag subscriptType (A.Subscript m sub) t = plainSubscriptType m sub t -subscriptType _ _ = die "unsubscriptable type" +subscriptType _ t = die $ "unsubscriptable type: " ++ show t -- | Just remove the first dimension from an array type -- like doing -- subscriptType with constant 0 as a subscript, but without the checking. @@ -108,7 +108,7 @@ subscriptType _ _ = die "unsubscriptable type" trivialSubscriptType :: (Die m) => A.Type -> m A.Type trivialSubscriptType (A.Array [d] t) = return t trivialSubscriptType (A.Array (d:ds) t) = return $ A.Array ds t -trivialSubscriptType _ = die "not plain array type" +trivialSubscriptType t = die $ "not plain array type: " ++ show t typeOfVariable :: (PSM m, Die m) => A.Variable -> m A.Type typeOfVariable (A.Variable m n) = typeOfName n