X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Frename%2FRnSource.lhs;h=5d23110e5fc9bdfa624d4cb761fd83c32a61468e;hp=6dce0346ea49213ee7cbd9c643edd59c8f90feb4;hb=302e2e29f2e1074bfba561e077a484dc4e1d15f6;hpb=c7c2a6b5ce0ea2fa010b193d059d4705a1791c40 diff --git a/compiler/rename/RnSource.lhs b/compiler/rename/RnSource.lhs index 6dce034..5d23110 100644 --- a/compiler/rename/RnSource.lhs +++ b/compiler/rename/RnSource.lhs @@ -1119,7 +1119,18 @@ addl gp (L l d : ds) = add gp l d ds add :: HsGroup RdrName -> SrcSpan -> HsDecl RdrName -> [LHsDecl RdrName] -> RnM (HsGroup RdrName, Maybe (SpliceDecl RdrName, [LHsDecl RdrName])) -add gp _ (SpliceD e) ds = return (gp, Just (e, ds)) +add gp loc (SpliceD splice@(SpliceDecl _ flag)) ds + = do { -- We've found a top-level splice. If it is an *implicit* one + -- (i.e. a naked top level expression) + case flag of + Explicit -> return () + Implicit -> do { th_on <- doptM Opt_TemplateHaskell + ; unless th_on $ setSrcSpan loc $ + failWith badImplicitSplice } + + ; return (gp, Just (splice, ds)) } + where + badImplicitSplice = ptext (sLit "Parse error: naked expression at top level") #ifndef GHCI add _ _ (QuasiQuoteD qq) _