[commit: ghc] arcpatch-D1448: fix #10734 by adding braces to pretty-printing of let inside do (be88585)

git at git.haskell.org git at git.haskell.org
Sat Nov 7 22:31:08 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : arcpatch-D1448
Link       : http://ghc.haskell.org/trac/ghc/changeset/be8858570274821546ccabf75fe01c3dad80e337/ghc

>---------------------------------------------------------------

commit be8858570274821546ccabf75fe01c3dad80e337
Author: John Leo <leo at halfaya.org>
Date:   Sat Nov 7 17:28:37 2015 -0500

    fix #10734 by adding braces to pretty-printing of let inside do
    
    Test Plan: validate
    
    Reviewers: bgamari, austin, goldfire
    
    Reviewed By: goldfire
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1448
    
    GHC Trac Issues: #10734


>---------------------------------------------------------------

be8858570274821546ccabf75fe01c3dad80e337
 libraries/template-haskell/Language/Haskell/TH/Ppr.hs |  2 +-
 testsuite/tests/th/T10734.hs                          | 10 ++++++++++
 testsuite/tests/th/T10734.stdout                      |  3 +++
 testsuite/tests/th/all.T                              |  2 ++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
index 1768b15..2231373 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
@@ -184,7 +184,7 @@ pprMaybeExp i (Just e) = pprExp i e
 ------------------------------
 instance Ppr Stmt where
     ppr (BindS p e) = ppr p <+> text "<-" <+> ppr e
-    ppr (LetS ds) = text "let" <+> ppr ds
+    ppr (LetS ds) = text "let" <+> (braces $ sep $ punctuate semi $ map ppr ds)
     ppr (NoBindS e) = ppr e
     ppr (ParS sss) = sep $ punctuate (text "|")
                          $ map (sep . punctuate comma . map ppr) sss
diff --git a/testsuite/tests/th/T10734.hs b/testsuite/tests/th/T10734.hs
new file mode 100644
index 0000000..05aef86
--- /dev/null
+++ b/testsuite/tests/th/T10734.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import Language.Haskell.TH
+
+main :: IO ()
+main = do
+  pprint <$> runQ [| do { let { }; return (); } |]             >>= putStrLn
+  pprint <$> runQ [| do { let { x = 5 }; return x; } |]        >>= putStrLn
+  pprint <$> runQ [| do { let { x = 5; y = 3 }; return x; } |] >>= putStrLn
diff --git a/testsuite/tests/th/T10734.stdout b/testsuite/tests/th/T10734.stdout
new file mode 100644
index 0000000..4a8b39a
--- /dev/null
+++ b/testsuite/tests/th/T10734.stdout
@@ -0,0 +1,3 @@
+do {let {}; GHC.Base.return GHC.Tuple.()}
+do {let {x_0 = 5}; GHC.Base.return x_0}
+do {let {x_0 = 5; y_1 = 3}; GHC.Base.return x_0}
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 2a040f2..5e8e611 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -364,3 +364,5 @@ test('T10810', normal, compile, ['-v0'])
 test('T10891', normal, compile, ['-v0'])
 test('T10945', normal, compile_fail, ['-v0'])
 test('T10946', expect_broken(10946), compile, ['-v0'])
+test('T10734', normal, compile_and_run, ['-v0'])
+



More information about the ghc-commits mailing list