summaryrefslogtreecommitdiff
path: root/compiler/hsSyn
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2010-05-06 16:15:23 +0000
committersimonpj@microsoft.com <unknown>2010-05-06 16:15:23 +0000
commit302e2e29f2e1074bfba561e077a484dc4e1d15f6 (patch)
treea5fc708696c16bb2a7fa446d0691cc1af904713c /compiler/hsSyn
parentc7c2a6b5ce0ea2fa010b193d059d4705a1791c40 (diff)
downloadhaskell-302e2e29f2e1074bfba561e077a484dc4e1d15f6.tar.gz
Add a HsExplicitFlag to SpliceDecl, to improve Trac #4042
The issue here is that g :: A -> A f data A = A is treated as if you'd written $(f); that is the call of f is a top-level Template Haskell splice. This patch makes sure that we *first* check the -XTemplateHaskellFlag and bleat about a parse error if it's off. Othewise we get strange seeing "A is out of scope" errors.
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r--compiler/hsSyn/HsDecls.lhs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs
index 0038ebed0a..baf6eca76f 100644
--- a/compiler/hsSyn/HsDecls.lhs
+++ b/compiler/hsSyn/HsDecls.lhs
@@ -232,11 +232,15 @@ instance OutputableBndr name => Outputable (HsGroup name) where
ppr_ds [] = empty
ppr_ds ds = blankLine $$ vcat (map ppr ds)
-data SpliceDecl id = SpliceDecl (Located (HsExpr id)) -- Top level splice
+data SpliceDecl id
+ = SpliceDecl -- Top level splice
+ (Located (HsExpr id))
+ HsExplicitFlag -- Explicit <=> $(f x y)
+ -- Implicit <=> f x y, i.e. a naked top level expression
deriving (Data, Typeable)
instance OutputableBndr name => Outputable (SpliceDecl name) where
- ppr (SpliceDecl e) = ptext (sLit "$") <> parens (pprExpr (unLoc e))
+ ppr (SpliceDecl e _) = ptext (sLit "$") <> parens (pprExpr (unLoc e))
\end{code}