summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcRnDriver.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 85d5a2ade1..2ac45fc224 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