Commit a501c950 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Make sure that we check for type errors strictly in a Template Haskell splice,...

Make sure that we check for type errors strictly in a Template Haskell splice, even if -fdefer-type-errors is on

We're going to run this code, so there's no point in deferring type
errors.  Worse, TcSplice uses unsafeCoerce (for vevy good reasons),
so splicing a type into a place where an expression is expected would
yield a seg-fault if we plough on regardless.

Fixes Trac #7276
parent 2c207b6f
......@@ -497,6 +497,12 @@ tcTopSpliceExpr :: TcM (LHsExpr Id) -> TcM (LHsExpr Id)
tcTopSpliceExpr tc_action
= checkNoErrs $ -- checkNoErrs: must not try to run the thing
-- if the type checker fails!
unsetDOptM Opt_DeferTypeErrors $
-- Don't defer type errors. Not only are we
-- going to run this code, but we do an unsafe
-- coerce, so we get a seg-fault if, say we
-- splice a type into a place where an expression
-- is expected (Trac #7276)
setStage Splice $
do { -- Typecheck the expression
(expr', lie) <- captureConstraints tc_action
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment