[commit: ghc] master: Fix for ticket #10078: ensure that tcPluginStop is called even in case of type errors (fd581a7)

git at git.haskell.org git at git.haskell.org
Mon Feb 23 09:40:26 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/fd581a7300abede9a070cb6e9b835b2e18f68b0b/ghc

>---------------------------------------------------------------

commit fd581a7300abede9a070cb6e9b835b2e18f68b0b
Author: Jan Bracker <jan.bracker at googlemail.com>
Date:   Mon Feb 23 03:40:15 2015 -0600

    Fix for ticket #10078: ensure that tcPluginStop is called even in case of type errors
    
    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


>---------------------------------------------------------------

fd581a7300abede9a070cb6e9b835b2e18f68b0b
 compiler/typecheck/TcRnDriver.hs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 85d5a2a..2ac45fc 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -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



More information about the ghc-commits mailing list