From 0d45533cd54ef08fa1e8f432c3f1192c76556504 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones <simonpj@microsoft.com> Date: Wed, 29 Aug 2012 11:33:33 +0100 Subject: [PATCH] Fail earlier if there's an error in a type declaration This change means that we don't recover from erroneous type declarations, thereby reporting fewer errors. But trying to recover confused GHC (leading to a pattern match failure in the compiler Trac #7175), and it turned out to be tricky to fix that. So this patch takes the more conservative path of failing earlier, perhaps reporting fewer real errors. MERGED from commit d0ddde58f928a6b156d8061c406226c4fbb7cd22 --- compiler/typecheck/TcTyClsDecls.lhs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/typecheck/TcTyClsDecls.lhs b/compiler/typecheck/TcTyClsDecls.lhs index 930735c6676c..014c568e711d 100644 --- a/compiler/typecheck/TcTyClsDecls.lhs +++ b/compiler/typecheck/TcTyClsDecls.lhs @@ -147,11 +147,12 @@ tcTyClGroup boot_details tyclds -- expects well-formed TyCons ; tcExtendGlobalEnv tyclss $ do { traceTc "Starting validity check" (ppr tyclss) - ; mapM_ (recoverM (return ()) . addLocM checkValidTyCl) + ; checkNoErrs $ + mapM_ (recoverM (return ()) . addLocM checkValidTyCl) (flattenTyClDecls tyclds) -- We recover, which allows us to report multiple validity errors - -- even from successive groups. But we stop after all groups are - -- processed if we find any errors. + -- but we then fail if any are wrong. Lacking the checkNoErrs + -- we get Trac #7175 -- Step 4: Add the implicit things; -- we want them in the environment because -- GitLab