From 36f5406a714f0f1225377a7d601358ee7146fae8 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Thu, 25 May 2006 09:45:45 +0000 Subject: [PATCH] Improve error reporting in interface typechecking --- compiler/iface/IfaceEnv.lhs | 14 ++++++++------ compiler/iface/IfaceSyn.lhs | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/iface/IfaceEnv.lhs b/compiler/iface/IfaceEnv.lhs index 40b7d31..3c1db55 100644 --- a/compiler/iface/IfaceEnv.lhs +++ b/compiler/iface/IfaceEnv.lhs @@ -288,9 +288,10 @@ initOrigNames names = foldl extendOrigNameCache emptyModuleEnv names tcIfaceLclId :: OccName -> IfL Id tcIfaceLclId occ = do { lcl <- getLclEnv - ; return (lookupOccEnv (if_id_env lcl) occ - `orElse` - pprPanic "tcIfaceLclId" (ppr occ)) } + ; case (lookupOccEnv (if_id_env lcl) occ) of + Just ty_var -> return ty_var + Nothing -> failIfM (text "Iface id out of scope: " <+> ppr occ) + } refineIfaceIdEnv :: TypeRefinement -> IfL a -> IfL a refineIfaceIdEnv (tv_subst, _) thing_inside @@ -311,9 +312,10 @@ extendIfaceIdEnv ids thing_inside tcIfaceTyVar :: OccName -> IfL TyVar tcIfaceTyVar occ = do { lcl <- getLclEnv - ; return (lookupOccEnv (if_tv_env lcl) occ - `orElse` - pprPanic "tcIfaceTyVar" (ppr occ)) } + ; case (lookupOccEnv (if_tv_env lcl) occ) of + Just ty_var -> return ty_var + Nothing -> failIfM (text "Iface type variable out of scope: " <+> ppr occ) + } extendIfaceTyVarEnv :: [TyVar] -> IfL a -> IfL a extendIfaceTyVarEnv tyvars thing_inside diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs index d4a6eec..5309367 100644 --- a/compiler/iface/IfaceSyn.lhs +++ b/compiler/iface/IfaceSyn.lhs @@ -654,7 +654,6 @@ toIfaceExpr ext (Lit l) = IfaceLit l toIfaceExpr ext (Type ty) = IfaceType (toIfaceType ext ty) toIfaceExpr ext (Lam x b) = IfaceLam (toIfaceBndr ext x) (toIfaceExpr ext b) toIfaceExpr ext (App f a) = toIfaceApp ext f [a] --- gaw 2004 toIfaceExpr ext (Case s x ty as) = IfaceCase (toIfaceExpr ext s) (getOccName x) (toIfaceType ext ty) (map (toIfaceAlt ext) as) toIfaceExpr ext (Let b e) = IfaceLet (toIfaceBind ext b) (toIfaceExpr ext e) toIfaceExpr ext (Note n e) = IfaceNote (toIfaceNote ext n) (toIfaceExpr ext e) -- 1.7.10.4