summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Gen/Splice.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-07-30 09:38:54 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2021-07-30 12:05:11 +0100
commiteff51e2aca978ebd0ca08345fb1790d70f6bb7c8 (patch)
tree7cdb7fc0fc0b27bacb502d4fee336e9fe0e23fa1 /compiler/GHC/Tc/Gen/Splice.hs
parent54d6b20192fe6fc244248c7766533a768c591bae (diff)
downloadhaskell-wip/T20179.tar.gz
Catch type-checker exceptions when splicingwip/T20179
In GHC.Tc.Gen.Splice.tcTopSpliceExpr we were forgetting to catch exceptions. As a result we missed the kind error in the unsolved constraints. This patch has an easy fix, which cures #20179
Diffstat (limited to 'compiler/GHC/Tc/Gen/Splice.hs')
-rw-r--r--compiler/GHC/Tc/Gen/Splice.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs
index fcd1474afa..13cd3e71c9 100644
--- a/compiler/GHC/Tc/Gen/Splice.hs
+++ b/compiler/GHC/Tc/Gen/Splice.hs
@@ -754,11 +754,17 @@ tcTopSpliceExpr isTypedSplice tc_action
-- is expected (#7276)
setStage (Splice isTypedSplice) $
do { -- Typecheck the expression
- (expr', wanted) <- captureConstraints tc_action
- ; const_binds <- simplifyTop wanted
+ (mb_expr', wanted) <- tryCaptureConstraints tc_action
+ -- If tc_action fails (perhaps because of insoluble constraints)
+ -- we want to capture and report those constraints, else we may
+ -- just get a silent failure (#20179). Hence the 'try' part.
- -- Zonk it and tie the knot of dictionary bindings
- ; return $ mkHsDictLet (EvBinds const_binds) expr' }
+ ; const_binds <- simplifyTop wanted
+
+ ; case mb_expr' of
+ Nothing -> failM -- In this case simplifyTop should have
+ -- reported some errors
+ Just expr' -> return $ mkHsDictLet (EvBinds const_binds) expr' }
{-
************************************************************************