From: simonpj Date: Mon, 25 Jul 2005 11:24:24 +0000 (+0000) Subject: [project @ 2005-07-25 11:24:24 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~326 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=81115aa3bf42f30e24ab793ed08fd72ee54659fd;p=ghc-hetmet.git [project @ 2005-07-25 11:24:24 by simonpj] Better error recovery for type signatures --- diff --git a/ghc/compiler/typecheck/TcBinds.lhs b/ghc/compiler/typecheck/TcBinds.lhs index f410897..858512a 100644 --- a/ghc/compiler/typecheck/TcBinds.lhs +++ b/ghc/compiler/typecheck/TcBinds.lhs @@ -60,7 +60,7 @@ import SrcLoc ( Located(..), unLoc, getLoc ) import Bag import ErrUtils ( Message ) import Digraph ( SCC(..), stronglyConnComp, flattenSCC ) -import Maybes ( fromJust, isJust, orElse ) +import Maybes ( fromJust, isJust, orElse, catMaybes ) import Util ( singleton ) import BasicTypes ( TopLevelFlag(..), isTopLevel, isNotTopLevel, RecFlag(..), isNonRec ) @@ -882,17 +882,19 @@ Type signatures are tricky. See Note [Signature skolems] in TcType \begin{code} tcTySigs :: [LSig Name] -> TcM [TcSigInfo] -tcTySigs sigs = mappM tcTySig (filter isVanillaLSig sigs) +tcTySigs sigs = do { mb_sigs <- mappM tcTySig (filter isVanillaLSig sigs) + ; return (catMaybes mb_sigs) } -tcTySig :: LSig Name -> TcM TcSigInfo +tcTySig :: LSig Name -> TcM (Maybe TcSigInfo) tcTySig (L span (Sig (L _ name) ty)) - = setSrcSpan span $ + = recoverM (return Nothing) $ + setSrcSpan span $ do { sigma_ty <- tcHsSigType (FunSigCtxt name) ty ; (tvs, theta, tau) <- tcInstSigType name scoped_names sigma_ty ; loc <- getInstLoc (SigOrigin (SigSkol name)) - ; return (TcSigInfo { sig_id = mkLocalId name sigma_ty, - sig_tvs = tvs, sig_theta = theta, sig_tau = tau, - sig_scoped = scoped_names, sig_loc = loc }) } + ; return (Just (TcSigInfo { sig_id = mkLocalId name sigma_ty, + sig_tvs = tvs, sig_theta = theta, sig_tau = tau, + sig_scoped = scoped_names, sig_loc = loc })) } where -- The scoped names are the ones explicitly mentioned -- in the HsForAll. (There may be more in sigma_ty, because