diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-10-01 21:52:19 +0100 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-10-02 18:12:18 +0100 |
| commit | a501c950652d3cb56335781289f0f502c0cf2f4e (patch) | |
| tree | 478844fd93e5b2174ea841c4de7906f412744b6c | |
| parent | 2c207b6f60ba5d271f400747256e4a32ca8f7e63 (diff) | |
| download | haskell-a501c950652d3cb56335781289f0f502c0cf2f4e.tar.gz | |
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
| -rw-r--r-- | compiler/typecheck/TcSplice.lhs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/typecheck/TcSplice.lhs b/compiler/typecheck/TcSplice.lhs index 21a6b7ef87..c5f0af3ff1 100644 --- a/compiler/typecheck/TcSplice.lhs +++ b/compiler/typecheck/TcSplice.lhs @@ -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 |
