summaryrefslogtreecommitdiff
path: root/testsuite/tests/ado
diff options
context:
space:
mode:
authorKirill Elagin <kirelagin@gmail.com>2020-03-04 22:46:42 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-12 09:45:51 -0400
commit1f9db3e79bd0d70e5a1491174d540717f3bce2bf (patch)
tree96dfe80d14aeb2db96c667b1a806c94e21f9fb54 /testsuite/tests/ado
parentcb93a1a4405b448e83cad973f93dab3f7f050736 (diff)
downloadhaskell-1f9db3e79bd0d70e5a1491174d540717f3bce2bf.tar.gz
pretty-printer: Properly parenthesise LastStmt
After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ```
Diffstat (limited to 'testsuite/tests/ado')
-rw-r--r--testsuite/tests/ado/ado009.hs10
-rw-r--r--testsuite/tests/ado/ado009.stderr8
-rw-r--r--testsuite/tests/ado/all.T1
3 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/ado/ado009.hs b/testsuite/tests/ado/ado009.hs
new file mode 100644
index 0000000000..876a4fba90
--- /dev/null
+++ b/testsuite/tests/ado/ado009.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE ApplicativeDo #-}
+{-# OPTIONS_GHC -ddump-rn -dsuppress-uniques #-}
+
+module Test where
+
+-- Make sure the $ stripped from the last stmt is printed
+q :: IO ()
+q = do
+ a <- return ()
+ return $ (\_ -> ()) a
diff --git a/testsuite/tests/ado/ado009.stderr b/testsuite/tests/ado/ado009.stderr
new file mode 100644
index 0000000000..19a5defd4c
--- /dev/null
+++ b/testsuite/tests/ado/ado009.stderr
@@ -0,0 +1,8 @@
+
+==================== Renamer ====================
+Test.q :: IO ()
+Test.q
+ = do a <- return ()
+ return $ (\ _ -> ()) a
+
+
diff --git a/testsuite/tests/ado/all.T b/testsuite/tests/ado/all.T
index 634aae2314..11a9f4d6c8 100644
--- a/testsuite/tests/ado/all.T
+++ b/testsuite/tests/ado/all.T
@@ -6,6 +6,7 @@ test('ado005', normal, compile_fail, [''])
test('ado006', normal, compile, [''])
test('ado007', normal, compile, [''])
test('ado008', normal, compile, [''])
+test('ado009', normal, compile, [''])
test('T11607', normal, compile_and_run, [''])
test('ado-optimal', normal, compile_and_run, [''])
test('T12490', normal, compile, [''])