From 2d15eb800ccec15a5f5a09bf06d00c8f7a79451c Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 6 Apr 2008 18:43:01 +0000 Subject: [PATCH] Make pushTypeContext handle Infer as no context. --- frontends/OccamTypes.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 560146f..9963f29 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -569,7 +569,9 @@ evalBytesInType t -- | Run an operation in a given type context. inTypeContext :: Maybe A.Type -> PassM a -> PassM a inTypeContext ctx body - = do pushTypeContext ctx + = do pushTypeContext (case ctx of + Just A.Infer -> Nothing + _ -> ctx) v <- body popTypeContext return v @@ -894,10 +896,7 @@ inferTypes = applyExplicitM9 doExpression doDimension doSubscript _ -> diePC m $ formatCode "Table literal is not valid for type %" wantT -- An expression: descend into it with the right context. doArrayElem wantT (A.ArrayElemExpr e) - = do let ctx = case wantT of - A.Infer -> Nothing - _ -> Just wantT - e' <- inTypeContext ctx $ doExpression descend e + = do e' <- inTypeContext (Just wantT) $ doExpression descend e t <- typeOfExpression e' checkType (findMeta e') wantT t return (t, A.ArrayElemExpr e')