ghc-ignore-ANN-annotation
authorDebian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>
Wed, 1 Apr 2015 11:35:10 +0000 (11:35 +0000)
committerJoachim Breitner <nomeata@debian.org>
Wed, 1 Apr 2015 11:35:10 +0000 (11:35 +0000)
Gbp-Pq: Name ghc-ignore-ANN-annotation.patch

compiler/typecheck/TcAnnotations.lhs

index 1d495c0eec36db323822032d896a0274a3be0888..04719bcee60d84a6f496fa3cd9e8894ffd5619bf 100644 (file)
@@ -18,19 +18,26 @@ import Outputable
 import Module
 import TcExpr
 import {-# SOURCE #-} TcSplice ( runAnnotation )
-import FastString
 #endif
+
+import FastString
 \end{code}
 
 \begin{code}
 tcAnnotations :: [LAnnDecl Name] -> TcM [Annotation]
-tcAnnotations = mapM tcAnnotation
 
-tcAnnotation :: LAnnDecl Name -> TcM Annotation
 #ifndef GHCI
--- TODO: modify lexer so ANN pragmas are parsed as comments in a stage1 compiler, so developers don't see this error
-tcAnnotation (L _ (HsAnnotation _ expr)) = pprPanic "Cant do annotations without GHCi" (ppr expr)
+-- No GHCI; emit a warning (not an error) and ignore. cf Trac #4268
+tcAnnotations [] = return []
+tcAnnotations anns@(L loc _ : _)
+  = do { setSrcSpan loc $ addWarnTc $
+             (ptext (sLit "Ignoring ANN annotation") <> plural anns <> comma
+             <+> ptext (sLit "because this is a stage-1 compiler or doesn't support GHCi"))
+       ; return [] }
 #else
+tcAnnotations = mapM tcAnnotation
+
+tcAnnotation :: LAnnDecl Name -> TcM Annotation
 tcAnnotation ann@(L loc (HsAnnotation provenance expr)) = do
     -- Work out what the full target of this annotation was
     mod <- getModule