[commit: ghc] master: Make -XTemplateHaskell an error in a stage-1 compiler (except with -M) (4279665)

git at git.haskell.org git at git.haskell.org
Tue Nov 12 15:07:29 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4279665b08a5fed970b5eb37f85bde68bd7c68f9/ghc

>---------------------------------------------------------------

commit 4279665b08a5fed970b5eb37f85bde68bd7c68f9
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Nov 11 08:51:05 2013 +0000

    Make -XTemplateHaskell an error in a stage-1 compiler (except with -M)
    
    Fixes Trac #8519


>---------------------------------------------------------------

4279665b08a5fed970b5eb37f85bde68bd7c68f9
 compiler/main/DynFlags.hs |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index b88e294..53e5297 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -3115,10 +3115,18 @@ checkTemplateHaskellOk turn_on
   | otherwise
   = getCurLoc >>= \l -> upd (\d -> d { thOnLoc = l })
 #else
--- In stage 1, Template Haskell is simply illegal
+-- In stage 1, Template Haskell is simply illegal, except with -M
+-- We don't bleat with -M because there's no problem with TH there,
+-- and in fact GHC's build system does ghc -M of the DPH libraries
+-- with a stage1 compiler
 checkTemplateHaskellOk turn_on
-  | turn_on   = addWarn "Template Haskell requires GHC with interpreter support\n    Perhaps you are using a stage-1 compiler?"
+  | turn_on = do dfs <- liftEwM getCmdLineState
+                 case ghcMode dfs of
+                    MkDepend -> return ()
+                    _        -> addErr msg
   | otherwise = return ()
+  where
+    msg = "Template Haskell requires GHC with interpreter support\n    Perhaps you are using a stage-1 compiler?"
 #endif
 
 {- **********************************************************************



More information about the ghc-commits mailing list