summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-04-08 11:44:09 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-12 13:51:23 -0400
commit18cbff86ec0cd3d06e99e3a00753cd66153210b5 (patch)
treefa4e1780edcf158de1a711776e6fc98d3eb74cf9 /compiler/GHC/Tc
parent792d9289434cb7418a559cd4157ee3bfaef54c99 (diff)
downloadhaskell-18cbff86ec0cd3d06e99e3a00753cd66153210b5.tar.gz
template-haskell: Run TH splices with err_vars from current context
Otherwise, errors can go missing which arise when running the splices. Fixes #19470
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Gen/Splice.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs
index 4fadae964b..589513af97 100644
--- a/compiler/GHC/Tc/Gen/Splice.hs
+++ b/compiler/GHC/Tc/Gen/Splice.hs
@@ -674,7 +674,11 @@ tcTopSplice expr res_ty
-- See Note [Running typed splices in the zonker]
runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc)
runTopSplice (DelayedSplice lcl_env orig_expr res_ty q_expr)
- = setLclEnv lcl_env $ do {
+ = do
+ errs_var <- getErrsVar
+ setLclEnv lcl_env $ setErrsVar errs_var $ do {
+ -- Set the errs_var to the errs_var from the current context,
+ -- otherwise error messages can go missing in GHCi (#19470)
zonked_ty <- zonkTcType res_ty
; zonked_q_expr <- zonkTopLExpr q_expr
-- See Note [Collecting modFinalizers in typed splices].