summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2019-04-18 12:53:56 -0700
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-04-19 23:50:29 -0400
commit99dd5d6b8365ecc8748651395c503b2c0b82490e (patch)
treeeac883813baa2f1e53f54e3727c6f428987c7544 /compiler/parser
parente7280c93ef8f0685bbd63552b5b72c029907687e (diff)
downloadhaskell-99dd5d6b8365ecc8748651395c503b2c0b82490e.tar.gz
Haddock: support strict GADT args with docs
Rather than massaging the output of the parser to re-arrange docs and bangs, it is simpler to patch the two places in which the strictness info is needed (to accept that the `HsBangTy` may be inside an `HsDocTy`). Fixes #16585.
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/RdrHsSyn.hs28
1 files changed, 2 insertions, 26 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index 3582f13dcc..bfb83bc9b3 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -662,10 +662,8 @@ mkConDeclH98 name mb_forall mb_cxt args
, con_forall = noLoc $ isJust mb_forall
, con_ex_tvs = mb_forall `orElse` []
, con_mb_cxt = mb_cxt
- , con_args = args'
+ , con_args = args
, con_doc = Nothing }
- where
- args' = nudgeHsSrcBangs args
mkGadtDecl :: [Located RdrName]
-> LHsType GhcPs -- Always a HsForAllTy
@@ -676,7 +674,7 @@ mkGadtDecl names ty
, con_forall = cL l $ isLHsForAllTy ty'
, con_qvars = mkHsQTvs tvs
, con_mb_cxt = mcxt
- , con_args = args'
+ , con_args = args
, con_res_ty = res_ty
, con_doc = Nothing }
, anns1 ++ anns2)
@@ -693,7 +691,6 @@ mkGadtDecl names ty
= (Nothing, tau, ann)
(args, res_ty) = split_tau tau
- args' = nudgeHsSrcBangs args
-- See Note [GADT abstract syntax] in HsDecls
split_tau (dL->L _ (HsFunTy _ (dL->L loc (HsRecTy _ rf)) res_ty))
@@ -705,27 +702,6 @@ mkGadtDecl names ty
(ann++mkParensApiAnn l)
peel_parens ty ann = (ty, ann)
-nudgeHsSrcBangs :: HsConDeclDetails GhcPs -> HsConDeclDetails GhcPs
--- ^ This function ensures that fields with strictness or packedness
--- annotations put these annotations on an outer 'HsBangTy'.
---
--- The problem is that in the parser, strictness and packedness annotations
--- bind more tightly that docstrings. However, the expectation downstream of
--- the parser (by functions such as 'getBangType' and 'getBangStrictness')
--- is that docstrings bind more tightly so that 'HsBangTy' may end up as the
--- top-level type.
---
--- See #15206
-nudgeHsSrcBangs details
- = case details of
- PrefixCon as -> PrefixCon (map go as)
- RecCon r -> RecCon r
- InfixCon a1 a2 -> InfixCon (go a1) (go a2)
- where
- go (dL->L l (HsDocTy _ (dL->L _ (HsBangTy _ s lty)) lds)) =
- cL l (HsBangTy noExt s (addCLoc lty lds (HsDocTy noExt lty lds)))
- go lty = lty
-
setRdrNameSpace :: RdrName -> NameSpace -> RdrName
-- ^ This rather gruesome function is used mainly by the parser.