summaryrefslogtreecommitdiff
path: root/testsuite/tests/ado/ado009.hs
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/ado009.hs
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/ado009.hs')
-rw-r--r--testsuite/tests/ado/ado009.hs10
1 files changed, 10 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