summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2021-08-22 21:14:46 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-06 22:57:55 -0400
commit407d3b3a3a219dab56d0a36598c637aa45da61e1 (patch)
tree4e03381c68302e2a995c573b4b57a4250f12dbf5 /testsuite/tests/printer
parent5b41353355022c1247e0516d541b7f7fb49f0e29 (diff)
downloadhaskell-407d3b3a3a219dab56d0a36598c637aa45da61e1.tar.gz
EPA: order of semicolons and comments for top-level decls is wrong
A comment followed by a semicolon at the top level resulted in the preceding comments being attached to the following declaration. Capture the comments as belonging to the declaration preceding the semicolon instead. Closes #20258
Diffstat (limited to 'testsuite/tests/printer')
-rw-r--r--testsuite/tests/printer/Makefile5
-rw-r--r--testsuite/tests/printer/Test20258.hs79
-rw-r--r--testsuite/tests/printer/all.T2
3 files changed, 86 insertions, 0 deletions
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index e2081aee9c..4d2dad7b86 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -728,3 +728,8 @@ PprUnicodeSyntax:
PprCommentPlacement2:
$(CHECK_PPR) $(LIBDIR) PprCommentPlacement2.hs
$(CHECK_EXACT) $(LIBDIR) PprCommentPlacement2.hs
+
+.PHONY: Test20258
+Test20258:
+ $(CHECK_PPR) $(LIBDIR) Test20258.hs
+ $(CHECK_EXACT) $(LIBDIR) Test20258.hs
diff --git a/testsuite/tests/printer/Test20258.hs b/testsuite/tests/printer/Test20258.hs
new file mode 100644
index 0000000000..bfcad743ae
--- /dev/null
+++ b/testsuite/tests/printer/Test20258.hs
@@ -0,0 +1,79 @@
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE TemplateHaskell #-}
+module Test20258 where
+
+x = 1
+
+-- Comment
+;
+
+data Foo = Foo
+
+-- After TyClD
+;
+
+instance Monoid CIRB where
+ mempty = CIRB mempty mempty mempty mempty
+
+-- After InstD
+;
+
+deriving instance Eq (GenTickish 'TickishPassCore)
+
+-- After DerivD
+;
+
+transferCodingStr DeflateTransferCoding = "deflate"
+
+-- After ValD
+;
+
+getContentType :: Int
+
+-- After SigD
+;
+
+type MyMaybe :: Type -> Type
+
+-- After KindSigD
+;
+
+default (Integer)
+
+-- After DefD
+;
+
+foreign import ccall unsafe "isDoubleFinite" isDoubleFinite :: Double -> Int
+
+-- After ForD
+;
+
+{-# DEPRECATED foo2 [] #-}
+
+-- After WarningD
+;
+
+{-# ANN module FromA #-}
+
+-- After AnnD
+;
+
+{-# RULES "myrule2" id f = f #-}
+
+-- After RuleD
+;
+
+$foo
+
+-- After SpliceD
+;
+
+type role Representational representational
+
+-- After RoleAnnotD
+;
+
+getContentType = 1
+
+-- Note: skipping DocD, only generated in haddock mode
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 2a477cf83b..4b9c04c01c 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -169,3 +169,5 @@ test('PprT13747', ignore_stderr, makefile_test, ['PprT13747'])
test('PprBracesSemiDataDecl', ignore_stderr, makefile_test, ['PprBracesSemiDataDecl'])
test('PprUnicodeSyntax', ignore_stderr, makefile_test, ['PprUnicodeSyntax'])
test('PprCommentPlacement2', ignore_stderr, makefile_test, ['PprCommentPlacement2'])
+
+test('Test20258', ignore_stderr, makefile_test, ['Test20258'])