[Git][ghc/ghc][master] EPA: Fix comments in mkListSyntaxTy0
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Fri Apr 19 06:17:10 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
f0701585 by Alan Zimmerman at 2024-04-19T02:16:08-04:00
EPA: Fix comments in mkListSyntaxTy0
Also extend the test to confirm.
Addresses #24669, 1 of 4
- - - - -
3 changed files:
- compiler/GHC/Parser/PostProcess.hs
- testsuite/tests/printer/AnnotationNoListTuplePuns.hs
- + testsuite/tests/printer/AnnotationNoListTuplePuns.stdout
Changes:
=====================================
compiler/GHC/Parser/PostProcess.hs
=====================================
@@ -3317,12 +3317,12 @@ withCombinedComments ::
HasLoc l2 =>
l1 ->
l2 ->
- (SrcSpan -> EpAnnComments -> P a) ->
+ (SrcSpan -> P a) ->
P (LocatedA a)
withCombinedComments start end use = do
cs <- getCommentsFor fullSpan
- a <- use fullSpan cs
- pure (L (noAnnSrcSpan fullSpan) a)
+ a <- use fullSpan
+ pure (L (EpAnn (spanAsAnchor fullSpan) noAnn cs) a)
where
fullSpan = combineSrcSpans (getHasLoc start) (getHasLoc end)
@@ -3362,15 +3362,14 @@ mkTupleSyntaxTycon boxity n =
mkListSyntaxTy0 :: EpaLocation
-> EpaLocation
-> SrcSpan
- -> EpAnnComments
-> P (HsType GhcPs)
-mkListSyntaxTy0 brkOpen brkClose span comments =
+mkListSyntaxTy0 brkOpen brkClose span =
punsIfElse enabled disabled
where
enabled = HsTyVar noAnn NotPromoted rn
-- attach the comments only to the RdrName since it's the innermost AST node
- rn = L (EpAnn fullLoc rdrNameAnn comments) listTyCon_RDR
+ rn = L (EpAnn fullLoc rdrNameAnn emptyComments) listTyCon_RDR
disabled =
HsExplicitListTy annsKeyword NotPromoted []
=====================================
testsuite/tests/printer/AnnotationNoListTuplePuns.hs
=====================================
@@ -1,17 +1,18 @@
{-# language NoListTuplePuns #-}
+{-# OPTIONS -ddump-parsed-ast #-}
module AnnotationNoListTuplePuns where
type A =
- -- comment pre
+ -- comment pre A
[
- -- comment inside
+ -- comment inside A
]
- -- comment post
+ -- comment post A
type B =
- -- comment pre
+ -- comment pre B
[
- -- comment inside
+ -- comment inside B
Bool
]
- -- comment post
+ -- comment post B
=====================================
testsuite/tests/printer/AnnotationNoListTuplePuns.stdout
=====================================
@@ -0,0 +1,323 @@
+
+==================== Parser AST ====================
+
+(L
+ { AnnotationNoListTuplePuns.hs:1:1 }
+ (HsModule
+ (XModulePs
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:1:1 })
+ (AnnsModule
+ [(AddEpAnn AnnModule (EpaSpan { AnnotationNoListTuplePuns.hs:3:1-6 }))
+ ,(AddEpAnn AnnWhere (EpaSpan { AnnotationNoListTuplePuns.hs:3:34-38 }))]
+ []
+ []
+ (Just
+ ((,)
+ { AnnotationNoListTuplePuns.hs:19:1 }
+ { AnnotationNoListTuplePuns.hs:18:3-19 })))
+ (EpaCommentsBalanced
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:1:1-32 })
+ (EpaComment
+ (EpaBlockComment
+ "{-# language NoListTuplePuns #-}")
+ { AnnotationNoListTuplePuns.hs:1:1 }))
+ ,(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:2:1-33 })
+ (EpaComment
+ (EpaBlockComment
+ "{-# OPTIONS -ddump-parsed-ast #-}")
+ { AnnotationNoListTuplePuns.hs:1:1-32 }))]
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:18:3-19 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment post B")
+ { AnnotationNoListTuplePuns.hs:17:3 }))]))
+ (EpVirtualBraces
+ (1))
+ (Nothing)
+ (Nothing))
+ (Just
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:3:8-32 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ {ModuleName: AnnotationNoListTuplePuns}))
+ (Nothing)
+ []
+ [(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:(5,1)-(9,3) })
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:6:3-18 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment pre A")
+ { AnnotationNoListTuplePuns.hs:5:8 }))]))
+ (TyClD
+ (NoExtField)
+ (SynDecl
+ [(AddEpAnn AnnType (EpaSpan { AnnotationNoListTuplePuns.hs:5:1-4 }))
+ ,(AddEpAnn AnnEqual (EpaSpan { AnnotationNoListTuplePuns.hs:5:8 }))]
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:5:6 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: A}))
+ (HsQTvs
+ (NoExtField)
+ [])
+ (Prefix)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:(7,3)-(9,3) })
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:8:5-23 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment inside A")
+ { AnnotationNoListTuplePuns.hs:7:3 }))]))
+ (HsExplicitListTy
+ [(AddEpAnn AnnOpenS (EpaSpan { AnnotationNoListTuplePuns.hs:7:3 }))
+ ,(AddEpAnn AnnCloseS (EpaSpan { AnnotationNoListTuplePuns.hs:9:3 }))]
+ (NotPromoted)
+ [])))))
+ ,(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:(12,1)-(17,3) })
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:10:3-19 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment post A")
+ { AnnotationNoListTuplePuns.hs:9:3 }))
+ ,(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:13:3-18 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment pre B")
+ { AnnotationNoListTuplePuns.hs:12:8 }))]))
+ (TyClD
+ (NoExtField)
+ (SynDecl
+ [(AddEpAnn AnnType (EpaSpan { AnnotationNoListTuplePuns.hs:12:1-4 }))
+ ,(AddEpAnn AnnEqual (EpaSpan { AnnotationNoListTuplePuns.hs:12:8 }))]
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:12:6 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: B}))
+ (HsQTvs
+ (NoExtField)
+ [])
+ (Prefix)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:(14,3)-(17,3) })
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.hs:15:5-23 })
+ (EpaComment
+ (EpaLineComment
+ "-- comment inside B")
+ { AnnotationNoListTuplePuns.hs:14:3 }))]))
+ (HsExplicitListTy
+ [(AddEpAnn AnnOpenS (EpaSpan { AnnotationNoListTuplePuns.hs:14:3 }))
+ ,(AddEpAnn AnnCloseS (EpaSpan { AnnotationNoListTuplePuns.hs:17:3 }))]
+ (NotPromoted)
+ [(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:16:5-8 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (HsTyVar
+ []
+ (NotPromoted)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.hs:16:5-8 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: Bool}))))])))))]))
+
+
+
+==================== Parser AST ====================
+
+(L
+ { AnnotationNoListTuplePuns.ppr.hs:1:1 }
+ (HsModule
+ (XModulePs
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:1:1 })
+ (AnnsModule
+ [(AddEpAnn AnnModule (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:3:1-6 }))
+ ,(AddEpAnn AnnWhere (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:3:34-38 }))]
+ []
+ []
+ (Just
+ ((,)
+ { AnnotationNoListTuplePuns.ppr.hs:5:16 }
+ { AnnotationNoListTuplePuns.ppr.hs:5:15 })))
+ (EpaCommentsBalanced
+ [(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.ppr.hs:1:1-32 })
+ (EpaComment
+ (EpaBlockComment
+ "{-# language NoListTuplePuns #-}")
+ { AnnotationNoListTuplePuns.ppr.hs:1:1 }))
+ ,(L
+ (EpaSpan
+ { AnnotationNoListTuplePuns.ppr.hs:2:1-33 })
+ (EpaComment
+ (EpaBlockComment
+ "{-# OPTIONS -ddump-parsed-ast #-}")
+ { AnnotationNoListTuplePuns.ppr.hs:1:1-32 }))]
+ []))
+ (EpVirtualBraces
+ (1))
+ (Nothing)
+ (Nothing))
+ (Just
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:3:8-32 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ {ModuleName: AnnotationNoListTuplePuns}))
+ (Nothing)
+ []
+ [(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:1-11 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (TyClD
+ (NoExtField)
+ (SynDecl
+ [(AddEpAnn AnnType (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:1-4 }))
+ ,(AddEpAnn AnnEqual (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:8 }))]
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:6 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: A}))
+ (HsQTvs
+ (NoExtField)
+ [])
+ (Prefix)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:10-11 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (HsExplicitListTy
+ [(AddEpAnn AnnOpenS (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:10 }))
+ ,(AddEpAnn AnnCloseS (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:11 }))]
+ (NotPromoted)
+ [])))))
+ ,(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:1-15 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (TyClD
+ (NoExtField)
+ (SynDecl
+ [(AddEpAnn AnnType (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:1-4 }))
+ ,(AddEpAnn AnnEqual (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:8 }))]
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:6 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: B}))
+ (HsQTvs
+ (NoExtField)
+ [])
+ (Prefix)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:10-15 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (HsExplicitListTy
+ [(AddEpAnn AnnOpenS (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:10 }))
+ ,(AddEpAnn AnnCloseS (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:15 }))]
+ (NotPromoted)
+ [(L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:11-14 })
+ (AnnListItem
+ [])
+ (EpaComments
+ []))
+ (HsTyVar
+ []
+ (NotPromoted)
+ (L
+ (EpAnn
+ (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:5:11-14 })
+ (NameAnnTrailing
+ [])
+ (EpaComments
+ []))
+ (Unqual
+ {OccName: Bool}))))])))))]))
+
+
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f07015858fd79dca41983dbf3a249dfecd8d2eea
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f07015858fd79dca41983dbf3a249dfecd8d2eea
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240419/b2c7e308/attachment-0001.html>
More information about the ghc-commits
mailing list