summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2022-04-10 16:37:16 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-05-23 21:04:49 -0400
commite9fff12b34bb9770491d24eff5c280f44dc8cfc1 (patch)
tree13007782780918e0b69f27d1157a3d4d487997d1 /testsuite/tests/ghc-api
parent1a4195b04866ebdb5f42006fb92b8a73a4aa2bac (diff)
downloadhaskell-e9fff12b34bb9770491d24eff5c280f44dc8cfc1.tar.gz
EPA : Remove duplicate comments in DataFamInstD
The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r--testsuite/tests/ghc-api/exactprint/Test20239.hs7
-rw-r--r--testsuite/tests/ghc-api/exactprint/Test20239.stderr327
-rw-r--r--testsuite/tests/ghc-api/exactprint/all.T1
3 files changed, 335 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-api/exactprint/Test20239.hs b/testsuite/tests/ghc-api/exactprint/Test20239.hs
new file mode 100644
index 0000000000..4f7d1e6216
--- /dev/null
+++ b/testsuite/tests/ghc-api/exactprint/Test20239.hs
@@ -0,0 +1,7 @@
+module Test20239 where
+
+-- | Leading Haddock Comment
+data instance Method PGMigration = MigrationQuery Query
+ -- ^ Run a query against the database
+ | MigrationCode (Connection -> IO (Either String ()))
+ -- ^ Run any arbitrary IO code
diff --git a/testsuite/tests/ghc-api/exactprint/Test20239.stderr b/testsuite/tests/ghc-api/exactprint/Test20239.stderr
new file mode 100644
index 0000000000..bada9845ab
--- /dev/null
+++ b/testsuite/tests/ghc-api/exactprint/Test20239.stderr
@@ -0,0 +1,327 @@
+
+==================== Parser AST ====================
+
+(L
+ { Test20239.hs:1:1 }
+ (HsModule
+ (EpAnn
+ (Anchor
+ { Test20239.hs:1:1 }
+ (UnchangedAnchor))
+ (AnnsModule
+ [(AddEpAnn AnnModule (EpaSpan { Test20239.hs:1:1-6 }))
+ ,(AddEpAnn AnnWhere (EpaSpan { Test20239.hs:1:18-22 }))]
+ (AnnList
+ (Nothing)
+ (Nothing)
+ (Nothing)
+ []
+ []))
+ (EpaCommentsBalanced
+ [(L
+ (Anchor
+ { Test20239.hs:3:1-28 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- | Leading Haddock Comment")
+ { Test20239.hs:1:18-22 }))]
+ [(L
+ (Anchor
+ { Test20239.hs:8:1 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaEofComment)
+ { Test20239.hs:7:34-63 }))]))
+ (VirtualBraces
+ (1))
+ (Just
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:1:8-16 })
+ {ModuleName: Test20239}))
+ (Nothing)
+ []
+ [(L
+ (SrcSpanAnn (EpAnn
+ (Anchor
+ { Test20239.hs:(4,1)-(6,86) }
+ (UnchangedAnchor))
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (Anchor
+ { Test20239.hs:7:34-63 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- ^ Run any arbitrary IO code")
+ { Test20239.hs:6:86 }))])) { Test20239.hs:(4,1)-(6,86) })
+ (InstD
+ (NoExtField)
+ (DataFamInstD
+ (NoExtField)
+ (DataFamInstDecl
+ (FamEqn
+ (EpAnn
+ (Anchor
+ { Test20239.hs:(4,1)-(6,86) }
+ (UnchangedAnchor))
+ [(AddEpAnn AnnData (EpaSpan { Test20239.hs:4:1-4 }))
+ ,(AddEpAnn AnnInstance (EpaSpan { Test20239.hs:4:6-13 }))
+ ,(AddEpAnn AnnEqual (EpaSpan { Test20239.hs:4:34 }))]
+ (EpaComments
+ [(L
+ (Anchor
+ { Test20239.hs:5:34-70 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- ^ Run a query against the database")
+ { Test20239.hs:4:51-55 }))]))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:15-20 })
+ (Unqual
+ {OccName: Method}))
+ (HsOuterImplicit
+ (NoExtField))
+ [(HsValArg
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:22-32 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:4:22-32 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:22-32 })
+ (Unqual
+ {OccName: PGMigration})))))]
+ (Prefix)
+ (HsDataDefn
+ (NoExtField)
+ (DataType)
+ (Nothing)
+ (Nothing)
+ (Nothing)
+ [(L
+ (SrcSpanAnn (EpAnn
+ (Anchor
+ { Test20239.hs:4:36-55 }
+ (UnchangedAnchor))
+ (AnnListItem
+ [(AddVbarAnn
+ (EpaSpan { Test20239.hs:6:34 }))])
+ (EpaComments
+ [])) { Test20239.hs:4:36-55 })
+ (ConDeclH98
+ (EpAnn
+ (Anchor
+ { Test20239.hs:4:36-55 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:36-49 })
+ (Unqual
+ {OccName: MigrationQuery}))
+ (False)
+ []
+ (Nothing)
+ (PrefixCon
+ []
+ [(HsScaled
+ (HsLinearArrow
+ (HsPct1
+ (L
+ (NoTokenLoc)
+ (HsTok))
+ (L
+ (NoTokenLoc)
+ (HsNormalTok))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:51-55 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:4:51-55 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:4:51-55 })
+ (Unqual
+ {OccName: Query})))))])
+ (Nothing)))
+ ,(L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:36-86 })
+ (ConDeclH98
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:36-86 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:36-48 })
+ (Unqual
+ {OccName: MigrationCode}))
+ (False)
+ []
+ (Nothing)
+ (PrefixCon
+ []
+ [(HsScaled
+ (HsLinearArrow
+ (HsPct1
+ (L
+ (NoTokenLoc)
+ (HsTok))
+ (L
+ (NoTokenLoc)
+ (HsNormalTok))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:50-86 })
+ (HsParTy
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:50 }
+ (UnchangedAnchor))
+ (AnnParen
+ (AnnParens)
+ (EpaSpan { Test20239.hs:6:50 })
+ (EpaSpan { Test20239.hs:6:86 }))
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:51-85 })
+ (HsFunTy
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:51-60 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (HsUnrestrictedArrow
+ (L
+ (TokenLoc
+ (EpaSpan { Test20239.hs:6:62-63 }))
+ (HsNormalTok)))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:51-60 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:51-60 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:51-60 })
+ (Unqual
+ {OccName: Connection}))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:65-85 })
+ (HsAppTy
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:65-66 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:65-66 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:65-66 })
+ (Unqual
+ {OccName: IO}))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:68-85 })
+ (HsParTy
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:68 }
+ (UnchangedAnchor))
+ (AnnParen
+ (AnnParens)
+ (EpaSpan { Test20239.hs:6:68 })
+ (EpaSpan { Test20239.hs:6:85 }))
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:69-84 })
+ (HsAppTy
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:69-81 })
+ (HsAppTy
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:69-74 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:69-74 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:69-74 })
+ (Unqual
+ {OccName: Either}))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:76-81 })
+ (HsTyVar
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:76-81 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (NotPromoted)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:76-81 })
+ (Unqual
+ {OccName: String}))))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:6:83-84 })
+ (HsTupleTy
+ (EpAnn
+ (Anchor
+ { Test20239.hs:6:83 }
+ (UnchangedAnchor))
+ (AnnParen
+ (AnnParens)
+ (EpaSpan { Test20239.hs:6:83 })
+ (EpaSpan { Test20239.hs:6:84 }))
+ (EpaComments
+ []))
+ (HsBoxedOrConstraintTuple)
+ [])))))))))))))])
+ (Nothing)))]
+ []))))))]
+ (Nothing)
+ (Nothing)))
+
+
+
+Test20239.hs:4:15:
+ Not in scope: type constructor or class ‘Method’
diff --git a/testsuite/tests/ghc-api/exactprint/all.T b/testsuite/tests/ghc-api/exactprint/all.T
index 385b74a243..97d94b566c 100644
--- a/testsuite/tests/ghc-api/exactprint/all.T
+++ b/testsuite/tests/ghc-api/exactprint/all.T
@@ -36,3 +36,4 @@ test('RmTypeSig1', ignore_stderr, makefile_test, ['RmTypeSig1'])
test('RmTypeSig2', ignore_stderr, makefile_test, ['RmTypeSig2'])
test('AddHiding1', ignore_stderr, makefile_test, ['AddHiding1'])
test('AddHiding2', ignore_stderr, makefile_test, ['AddHiding2'])
+test('Test20239', normal, compile_fail, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments'])