diff options
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/DumpParsedAst.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/DumpParsedAst.stderr | 583 |
3 files changed, 571 insertions, 21 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 81082534e9..ef3f279567 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -746,8 +746,7 @@ 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 = case outer_bndrs of - _ -> EpAnn (spanAsAnchor loc) (annsIn ++ annsa) (cs Semi.<> csa) + let an = EpAnn (spanAsAnchor loc) (annsIn ++ annsa) (cs Semi.<> csa) pure $ L l ConDeclGADT { con_g_ext = an diff --git a/testsuite/tests/parser/should_compile/DumpParsedAst.hs b/testsuite/tests/parser/should_compile/DumpParsedAst.hs index 15b37b683c..b6c52be15b 100644 --- a/testsuite/tests/parser/should_compile/DumpParsedAst.hs +++ b/testsuite/tests/parser/should_compile/DumpParsedAst.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Haskell2010 #-} -{-# LANGUAGE DataKinds, PolyKinds, TypeOperators, TypeFamilies +{-# LANGUAGE DataKinds, GADTs, PolyKinds, RankNTypes, TypeOperators, TypeFamilies , TypeApplications, TypeInType #-} module DumpParsedAst where @@ -17,4 +17,8 @@ data T f (a :: k) = MkT (f a) type family F1 (a :: k) (f :: k -> Type) :: Type where F1 @Peano a f = T @Peano f a +data family Nat :: k -> k -> Type +newtype instance Nat (a :: k -> Type) :: (k -> Type) -> Type where + Nat :: (forall xx. f xx -> g xx) -> Nat f g + main = putStrLn "hello" diff --git a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr index 38e55e1021..0f41f9a4d0 100644 --- a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr @@ -21,11 +21,11 @@ [] [(L (Anchor - { DumpParsedAst.hs:21:1 } + { DumpParsedAst.hs:25:1 } (UnchangedAnchor)) (EpaComment (EpaEofComment) - { DumpParsedAst.hs:21:1 }))])) + { DumpParsedAst.hs:25:1 }))])) (VirtualBraces (1)) (Just @@ -900,37 +900,584 @@ ,(L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAst.hs:20:1-23 } + { DumpParsedAst.hs:20:1-33 } (UnchangedAnchor)) (AnnListItem []) (EpaComments - [])) { DumpParsedAst.hs:20:1-23 }) + [])) { DumpParsedAst.hs:20:1-33 }) + (TyClD + (NoExtField) + (FamDecl + (NoExtField) + (FamilyDecl + (EpAnn + (Anchor + { DumpParsedAst.hs:20:1-33 } + (UnchangedAnchor)) + [(AddEpAnn AnnData (EpaSpan { DumpParsedAst.hs:20:1-4 })) + ,(AddEpAnn AnnFamily (EpaSpan { DumpParsedAst.hs:20:6-11 })) + ,(AddEpAnn AnnDcolon (EpaSpan { DumpParsedAst.hs:20:17-18 }))] + (EpaComments + [])) + (DataFamily) + (TopLevel) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:13-15 }) + (Unqual + {OccName: Nat})) + (HsQTvs + (NoExtField) + []) + (Prefix) + (L + (SrcSpanAnn + (EpAnnNotUsed) + { DumpParsedAst.hs:20:17-33 }) + (KindSig + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:20-33 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:20:20 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:20:22-23 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:20 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:20:20 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:20 }) + (Unqual + {OccName: k})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:25-33 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:20:25 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:20:27-28 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:25 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:20:25 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:25 }) + (Unqual + {OccName: k})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:30-33 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:20:30-33 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:30-33 }) + (Unqual + {OccName: Type})))))))))) + (Nothing))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpParsedAst.hs:(21,1)-(22,45) } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpParsedAst.hs:(21,1)-(22,45) }) + (InstD + (NoExtField) + (DataFamInstD + (EpAnn + (Anchor + { DumpParsedAst.hs:(21,1)-(22,45) } + (UnchangedAnchor)) + [(AddEpAnn AnnNewtype (EpaSpan { DumpParsedAst.hs:21:1-7 })) + ,(AddEpAnn AnnInstance (EpaSpan { DumpParsedAst.hs:21:9-16 })) + ,(AddEpAnn AnnDcolon (EpaSpan { DumpParsedAst.hs:21:39-40 })) + ,(AddEpAnn AnnWhere (EpaSpan { DumpParsedAst.hs:21:62-66 }))] + (EpaComments + [])) + (DataFamInstDecl + (FamEqn + (EpAnn + (Anchor + { DumpParsedAst.hs:(21,1)-(22,45) } + (UnchangedAnchor)) + [(AddEpAnn AnnNewtype (EpaSpan { DumpParsedAst.hs:21:1-7 })) + ,(AddEpAnn AnnInstance (EpaSpan { DumpParsedAst.hs:21:9-16 })) + ,(AddEpAnn AnnDcolon (EpaSpan { DumpParsedAst.hs:21:39-40 })) + ,(AddEpAnn AnnWhere (EpaSpan { DumpParsedAst.hs:21:62-66 }))] + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:18-20 }) + (Unqual + {OccName: Nat})) + (HsOuterImplicit + (NoExtField)) + [(HsValArg + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:22-37 }) + (HsParTy + (EpAnn + (Anchor + { DumpParsedAst.hs:21:22 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpParsedAst.hs:21:22 }) + (EpaSpan { DumpParsedAst.hs:21:37 })) + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:23-36 }) + (HsKindSig + (EpAnn + (Anchor + { DumpParsedAst.hs:21:23 } + (UnchangedAnchor)) + [(AddEpAnn AnnDcolon (EpaSpan { DumpParsedAst.hs:21:25-26 }))] + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:23 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:23 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:23 }) + (Unqual + {OccName: a})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:28-36 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:21:28 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:21:30-31 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:28 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:28 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:28 }) + (Unqual + {OccName: k})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:33-36 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:33-36 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:33-36 }) + (Unqual + {OccName: Type})))))))))))] + (Prefix) + (HsDataDefn + (NoExtField) + (NewType) + (Nothing) + (Nothing) + (Just + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:42-60 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:21:42-52 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:21:54-55 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:42-52 }) + (HsParTy + (EpAnn + (Anchor + { DumpParsedAst.hs:21:42 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpParsedAst.hs:21:42 }) + (EpaSpan { DumpParsedAst.hs:21:52 })) + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:43-51 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:21:43 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:21:45-46 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:43 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:43 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:43 }) + (Unqual + {OccName: k})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:48-51 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:48-51 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:48-51 }) + (Unqual + {OccName: Type})))))))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:57-60 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:21:57-60 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:21:57-60 }) + (Unqual + {OccName: Type}))))))) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:3-45 }) + (ConDeclGADT + (EpAnn + (Anchor + { DumpParsedAst.hs:22:3-45 } + (UnchangedAnchor)) + [(AddEpAnn AnnDcolon (EpaSpan { DumpParsedAst.hs:22:7-8 }))] + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:3-5 }) + (Unqual + {OccName: Nat}))] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:10-45 }) + (HsOuterImplicit + (NoExtField))) + (Nothing) + (PrefixConGADT + [(HsScaled + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:22:36-37 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpParsedAst.hs:22:10-34 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpParsedAst.hs:22:10-34 }) + (HsParTy + (EpAnn + (Anchor + { DumpParsedAst.hs:22:10 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpParsedAst.hs:22:10 }) + (EpaSpan { DumpParsedAst.hs:22:34 })) + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:11-33 }) + (HsForAllTy + (NoExtField) + (HsForAllInvis + (EpAnn + (Anchor + { DumpParsedAst.hs:22:11-16 } + (UnchangedAnchor)) + ((,) + (AddEpAnn AnnForall (EpaSpan { DumpParsedAst.hs:22:11-16 })) + (AddEpAnn AnnDot (EpaSpan { DumpParsedAst.hs:22:20 }))) + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:18-19 }) + (UserTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:18-19 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (SpecifiedSpec) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:18-19 }) + (Unqual + {OccName: xx}))))]) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:22-33 }) + (HsFunTy + (EpAnn + (Anchor + { DumpParsedAst.hs:22:22-25 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:22:27-28 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:22-25 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:22 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:22 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:22 }) + (Unqual + {OccName: f})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:24-25 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:24-25 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:24-25 }) + (Unqual + {OccName: xx})))))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:30-33 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:30 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:30 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:30 }) + (Unqual + {OccName: g})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:32-33 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:32-33 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:32-33 }) + (Unqual + {OccName: xx})))))))))))))]) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:39-45 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:39-43 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:39-41 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:39-41 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:39-41 }) + (Unqual + {OccName: Nat})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:43 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:43 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:43 }) + (Unqual + {OccName: f})))))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:45 }) + (HsTyVar + (EpAnn + (Anchor + { DumpParsedAst.hs:22:45 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:22:45 }) + (Unqual + {OccName: g})))))) + (Nothing)))] + [])))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpParsedAst.hs:24:1-23 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpParsedAst.hs:24:1-23 }) (ValD (NoExtField) (FunBind (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:1-4 }) (Unqual {OccName: main})) (MG (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:1-23 }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:1-23 }) (Match (EpAnn (Anchor - { DumpParsedAst.hs:20:1-23 } + { DumpParsedAst.hs:24:1-23 } (UnchangedAnchor)) [] (EpaComments [])) (FunRhs (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:1-4 }) (Unqual {OccName: main})) (Prefix) @@ -942,42 +1489,42 @@ [(L (SrcSpanAnn (EpAnnNotUsed) - { DumpParsedAst.hs:20:6-23 }) + { DumpParsedAst.hs:24:6-23 }) (GRHS (EpAnn (Anchor - { DumpParsedAst.hs:20:6-23 } + { DumpParsedAst.hs:24:6-23 } (UnchangedAnchor)) (GrhsAnn (Nothing) - (AddEpAnn AnnEqual (EpaSpan { DumpParsedAst.hs:20:6 }))) + (AddEpAnn AnnEqual (EpaSpan { DumpParsedAst.hs:24:6 }))) (EpaComments [])) [] (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:8-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:8-23 }) (HsApp (EpAnn (Anchor - { DumpParsedAst.hs:20:8-23 } + { DumpParsedAst.hs:24:8-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments [])) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:8-15 }) (HsVar (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:8-15 }) (Unqual {OccName: putStrLn})))) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:20:17-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:24:17-23 }) (HsLit (EpAnn (Anchor - { DumpParsedAst.hs:20:17-23 } + { DumpParsedAst.hs:24:17-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments |