Fix for ticket #10078: ensure that tcPluginStop is called even in case of type errors
authorJan Bracker <jan.bracker@googlemail.com>
Mon, 23 Feb 2015 09:40:15 +0000 (03:40 -0600)
committerAustin Seipp <austin@well-typed.com>
Mon, 23 Feb 2015 09:40:16 +0000 (03:40 -0600)
Summary:
Remove unused variable that appeared through the fix for ticket #10078

Merge branch 'master' of git://git.haskell.org/ghc

Added comment with bug ID.

Reviewers: adamgundry, gridaphobe, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D667

GHC Trac Issues: #10078

compiler/typecheck/TcRnDriver.hs

index 85d5a2a..2ac45fc 100644 (file)
@@ -2121,9 +2121,14 @@ withTcPlugins hsc_env m =
      case plugins of
        [] -> m  -- Common fast case
        _  -> do (solvers,stops) <- unzip `fmap` mapM startPlugin plugins
-                res <- updGblEnv (\e -> e { tcg_tc_plugins = solvers }) m
+                -- This ensures that tcPluginStop is called even if a type
+                -- error occurs during compilation (Fix of #10078)
+                eitherRes <- tryM $ do
+                  updGblEnv (\e -> e { tcg_tc_plugins = solvers }) m
                 mapM_ runTcPluginM stops
-                return res
+                case eitherRes of
+                  Left _ -> failM
+                  Right res -> return res
   where
   startPlugin (TcPlugin start solve stop) =
     do s <- runTcPluginM start