From e4032b1951a35d8df63a74ebfee7449988b5ef40 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 11 May 2015 10:57:25 +0200 Subject: ApiAnnotations : mkGadtDecl discards annotations for HsFunTy Summary: When mkGadtDecl is presented wih a HsFunTy it discards the SrcSpan, thus disconnecting any annotations on the HsFunTy. ``` mkGadtDecl names (L ls (HsForAllTy imp Nothing qvars cxt tau)) = return $ mk_gadt_con names where (details, res_ty) -- See Note [Sorting out the result type] = case tau of L _ (HsFunTy (L l (HsRecTy flds)) res_ty) -> (RecCon (L l flds), res_ty) _other -> (PrefixCon [], tau) ... ``` This can be triggered by the following ``` {-# LANGUAGE GADTs #-} module GADTRecords2 (H1(..)) where -- | h1 data H1 a b where C3 :: (Num a) => { field :: a -- ^ hello docs } -> H1 Int Int ``` Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D848 GHC Trac Issues: #10309 --- compiler/parser/Parser.y | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 1baf606173..3d9b2a39cb 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1621,7 +1621,8 @@ type :: { LHsType RdrName } : btype { $1 } | btype qtyconop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 } | btype tyvarop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 } - | btype '->' ctype {% ams (sLL $1 $> $ HsFunTy $1 $3) + | btype '->' ctype {% ams $1 [mj AnnRarrow $2] + >> ams (sLL $1 $> $ HsFunTy $1 $3) [mj AnnRarrow $2] } | btype '~' btype {% ams (sLL $1 $> $ HsEqTy $1 $3) [mj AnnTilde $2] } -- cgit v1.2.1