From: simonpj@microsoft.com Date: Thu, 25 May 2006 09:45:45 +0000 (+0000) Subject: Improve error reporting in interface typechecking X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=36f5406a714f0f1225377a7d601358ee7146fae8 Improve error reporting in interface typechecking --- 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)