diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs index 0ef169085bd55d7857889f464b7fd544c624d7ac..23501e3e1aa0bd7d7345e4a5bf3529520aaa76a2 100644 --- a/compiler/rename/RnExpr.lhs +++ b/compiler/rename/RnExpr.lhs @@ -189,8 +189,10 @@ rnExpr (HsSpliceE splice) rnExpr e@(HsQuasiQuoteE _) = pprPanic "Cant do quasiquotation without GHCi" (ppr e) #else rnExpr (HsQuasiQuoteE qq) - = runQuasiQuoteExpr qq `thenM` \ (L _ expr') -> - rnExpr expr' + = runQuasiQuoteExpr qq `thenM` \ lexpr' -> + -- Wrap the result of the quasi-quoter in parens so that we don't + -- lose the outermost location set by runQuasiQuote (#7918) + rnExpr (HsPar lexpr') #endif /* GHCI */ --------------------------------------------- diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs index 90a83d6a8e4aa9148a6c6badfe4a19667b2d87bf..e7cecf8f3f852b2eaf9dc821240a4116f100eb6f 100644 --- a/compiler/rename/RnPat.lhs +++ b/compiler/rename/RnPat.lhs @@ -416,8 +416,9 @@ rnPatAndThen _ p@(QuasiQuotePat {}) #else rnPatAndThen mk (QuasiQuotePat qq) = do { pat <- liftCps $ runQuasiQuotePat qq - ; L _ pat' <- rnLPatAndThen mk pat - ; return pat' } + -- Wrap the result of the quasi-quoter in parens so that we don't + -- lose the outermost location set by runQuasiQuote (#7918) + ; rnPatAndThen mk (ParPat pat) } #endif /* GHCI */ rnPatAndThen _ pat = pprPanic "rnLPatAndThen" (ppr pat) diff --git a/compiler/rename/RnTypes.lhs b/compiler/rename/RnTypes.lhs index a1c4bac25c8001b4193e0bfb9669297d36924206..c13ea336e4d0c778eeb66897a4c27feb52582635 100644 --- a/compiler/rename/RnTypes.lhs +++ b/compiler/rename/RnTypes.lhs @@ -269,7 +269,9 @@ rnHsTyKi _ _ ty@(HsQuasiQuoteTy _) = pprPanic "Can't do quasiquotation without G rnHsTyKi isType doc (HsQuasiQuoteTy qq) = ASSERT( isType ) do { ty <- runQuasiQuoteType qq - ; rnHsType doc (unLoc ty) } + -- Wrap the result of the quasi-quoter in parens so that we don't + -- lose the outermost location set by runQuasiQuote (#7918) + ; rnHsType doc (HsParTy ty) } #endif rnHsTyKi isType _ (HsCoreTy ty)