summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2022-04-01 14:33:55 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-08 13:56:27 -0400
commit3415981c36631115bc1d7fb5b51abfcc2932a12f (patch)
tree9546cc5fa07432c16aa60902250a1ad19a6c227c /compiler/GHC
parent85f4a3c9c2635e71a9ab0b723774ec993fefb93d (diff)
downloadhaskell-3415981c36631115bc1d7fb5b51abfcc2932a12f.tar.gz
HsUniToken for :: in GADT constructors (#19623)
One more step towards the new design of EPA. Updates the haddock submodule.
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Parser.y2
-rw-r--r--compiler/GHC/Parser/PostProcess.hs7
-rw-r--r--compiler/GHC/Parser/PostProcess/Haddock.hs4
-rw-r--r--compiler/GHC/Rename/Module.hs2
-rw-r--r--compiler/GHC/ThToHs.hs1
5 files changed, 10 insertions, 6 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index 381af647ba..01c0459866 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -2371,7 +2371,7 @@ gadt_constr :: { LConDecl GhcPs }
-- Returns a list because of: C,D :: ty
-- TODO:AZ capture the optSemi. Why leading?
: optSemi con_list '::' sigtype
- {% mkGadtDecl (comb2A $2 $>) (unLoc $2) $4 [mu AnnDcolon $3] }
+ {% mkGadtDecl (comb2A $2 $>) (unLoc $2) (hsUniTok $3) $4 }
{- Note [Difference in parsing GADT and data constructors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs
index c39cc478af..1530e9ab12 100644
--- a/compiler/GHC/Parser/PostProcess.hs
+++ b/compiler/GHC/Parser/PostProcess.hs
@@ -723,10 +723,10 @@ mkConDeclH98 ann name mb_forall mb_cxt args
-- Note [GADT abstract syntax] in "GHC.Hs.Decls" for more details.
mkGadtDecl :: SrcSpan
-> [LocatedN RdrName]
+ -> LHsUniToken "::" "∷" GhcPs
-> LHsSigType GhcPs
- -> [AddEpAnn]
-> P (LConDecl GhcPs)
-mkGadtDecl loc names ty annsIn = do
+mkGadtDecl loc names dcol ty = do
cs <- getCommentsFor loc
let l = noAnnSrcSpan loc
@@ -746,11 +746,12 @@ mkGadtDecl loc names ty annsIn = do
let (anns, cs, arg_types, res_type) = splitHsFunType body_ty
return (PrefixConGADT arg_types, res_type, anns, cs)
- let an = EpAnn (spanAsAnchor loc) (annsIn ++ annsa) (cs Semi.<> csa)
+ let an = EpAnn (spanAsAnchor loc) annsa (cs Semi.<> csa)
pure $ L l ConDeclGADT
{ con_g_ext = an
, con_names = names
+ , con_dcolon = dcol
, con_bndrs = L (getLoc ty) outer_bndrs
, con_mb_cxt = mcxt
, con_g_args = args
diff --git a/compiler/GHC/Parser/PostProcess/Haddock.hs b/compiler/GHC/Parser/PostProcess/Haddock.hs
index 271d9db30f..72403ef018 100644
--- a/compiler/GHC/Parser/PostProcess/Haddock.hs
+++ b/compiler/GHC/Parser/PostProcess/Haddock.hs
@@ -696,7 +696,7 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
addHaddock (L l_con_decl con_decl) =
extendHdkA (locA l_con_decl) $
case con_decl of
- ConDeclGADT { con_g_ext, con_names, con_bndrs, con_mb_cxt, con_g_args, con_res_ty } -> do
+ ConDeclGADT { con_g_ext, con_names, con_dcolon, con_bndrs, con_mb_cxt, con_g_args, con_res_ty } -> do
-- discardHasInnerDocs is ok because we don't need this info for GADTs.
con_doc' <- discardHasInnerDocs $ getConDoc (getLocA (head con_names))
con_g_args' <-
@@ -708,7 +708,7 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
pure $ RecConGADT (L l_rec flds') arr
con_res_ty' <- addHaddock con_res_ty
pure $ L l_con_decl $
- ConDeclGADT { con_g_ext, con_names, con_bndrs, con_mb_cxt,
+ ConDeclGADT { con_g_ext, con_names, con_dcolon, con_bndrs, con_mb_cxt,
con_doc = lexLHsDocString <$> con_doc',
con_g_args = con_g_args',
con_res_ty = con_res_ty' }
diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs
index 29937ea5f0..bc701e87bf 100644
--- a/compiler/GHC/Rename/Module.hs
+++ b/compiler/GHC/Rename/Module.hs
@@ -2350,6 +2350,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs
all_fvs) }}
rnConDecl (ConDeclGADT { con_names = names
+ , con_dcolon = dcol
, con_bndrs = L l outer_bndrs
, con_mb_cxt = mcxt
, con_g_args = args
@@ -2388,6 +2389,7 @@ rnConDecl (ConDeclGADT { con_names = names
(ppr names $$ ppr outer_bndrs')
; new_mb_doc <- traverse rnLHsDoc mb_doc
; return (ConDeclGADT { con_g_ext = noAnn, con_names = new_names
+ , con_dcolon = dcol
, con_bndrs = L l outer_bndrs', con_mb_cxt = new_cxt
, con_g_args = new_args, con_res_ty = new_res_ty
, con_doc = new_mb_doc },
diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs
index 194250aff8..931ea20796 100644
--- a/compiler/GHC/ThToHs.hs
+++ b/compiler/GHC/ThToHs.hs
@@ -703,6 +703,7 @@ mk_gadt_decl names args res_ty
returnLA $ ConDeclGADT
{ con_g_ext = noAnn
, con_names = names
+ , con_dcolon = noHsUniTok
, con_bndrs = bndrs
, con_mb_cxt = Nothing
, con_g_args = args