summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-04-08 11:44:09 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-04-08 11:45:04 +0100
commitda171284ed5119f8c33d1f0a4cc0a0ae52ca5d21 (patch)
tree6dca5b50509e8543f196c016bb9968a36c410526 /compiler
parent247684adc83f025d2ee329f4c98ae1f8829060b4 (diff)
downloadhaskell-wip/tth-ghci-errors.tar.gz
template-haskell: Run TH splices with err_vars from current contextwip/tth-ghci-errors
Otherwise, errors can go missing which arise when running the splices. Fixes #19470
Diffstat (limited to 'compiler')
-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].