Commit be885857 authored by johnleo's avatar johnleo Committed by eir@cis.upenn.edu

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
parent 6e6438e1
...@@ -184,7 +184,7 @@ pprMaybeExp i (Just e) = pprExp i e ...@@ -184,7 +184,7 @@ pprMaybeExp i (Just e) = pprExp i e
------------------------------ ------------------------------
instance Ppr Stmt where instance Ppr Stmt where
ppr (BindS p e) = ppr p <+> text "<-" <+> ppr e 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 (NoBindS e) = ppr e
ppr (ParS sss) = sep $ punctuate (text "|") ppr (ParS sss) = sep $ punctuate (text "|")
$ map (sep . punctuate comma . map ppr) sss $ map (sep . punctuate comma . map ppr) sss
......
{-# 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
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}
...@@ -364,3 +364,5 @@ test('T10810', normal, compile, ['-v0']) ...@@ -364,3 +364,5 @@ test('T10810', normal, compile, ['-v0'])
test('T10891', normal, compile, ['-v0']) test('T10891', normal, compile, ['-v0'])
test('T10945', normal, compile_fail, ['-v0']) test('T10945', normal, compile_fail, ['-v0'])
test('T10946', expect_broken(10946), compile, ['-v0']) test('T10946', expect_broken(10946), compile, ['-v0'])
test('T10734', normal, compile_and_run, ['-v0'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment