[commit: ghc] wip/T3384: Pretty printing HsCoreAnn properly (d6f3f5c)

git at git.haskell.org git at git.haskell.org
Sun Nov 13 21:05:28 UTC 2016


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

On branch  : wip/T3384
Link       : http://ghc.haskell.org/trac/ghc/changeset/d6f3f5cc9af85719c7efb38291e24277adad27cf/ghc

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

commit d6f3f5cc9af85719c7efb38291e24277adad27cf
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Sat Nov 12 11:55:40 2016 +0200

    Pretty printing HsCoreAnn properly


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

d6f3f5cc9af85719c7efb38291e24277adad27cf
 compiler/hsSyn/HsExpr.hs              |  2 +-
 testsuite/tests/printer/Makefile      |  4 ++++
 testsuite/tests/printer/Ppr009.hs     |  9 +++++++++
 testsuite/tests/printer/Ppr009.stderr | 28 ++++++++++++++++++++++++++++
 testsuite/tests/printer/all.T         |  1 +
 5 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index 024ebf6..d6e3d18 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -812,7 +812,7 @@ ppr_expr (HsOverLit lit)  = ppr lit
 ppr_expr (HsPar e)        = parens (ppr_lexpr e)
 
 ppr_expr (HsCoreAnn _ (StringLiteral _ s) e)
-  = vcat [text "HsCoreAnn" <+> ftext s, ppr_lexpr e]
+  = vcat [text "{-# CORE \"" <> ftext s <> text "\" #-}", ppr_lexpr e]
 
 ppr_expr e@(HsApp {})        = ppr_apps e []
 ppr_expr e@(HsAppType {})    = ppr_apps e []
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index 559aa63..534e5d8 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -37,3 +37,7 @@ ppr007:
 .PHONY: ppr008
 ppr008:
 	$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Ppr008.hs
+
+.PHONY: ppr009
+ppr009:
+	$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Ppr009.hs
diff --git a/testsuite/tests/printer/Ppr009.hs b/testsuite/tests/printer/Ppr009.hs
new file mode 100644
index 0000000..d24ecdc
--- /dev/null
+++ b/testsuite/tests/printer/Ppr009.hs
@@ -0,0 +1,9 @@
+module Ppr009 where
+
+
+{-# INLINE strictStream #-}
+strictStream (Bitstream l v)
+    = {-# CORE "Strict Bitstream stream" #-}
+      S.concatMap stream (GV.stream v)
+      `S.sized`
+      Exact l
diff --git a/testsuite/tests/printer/Ppr009.stderr b/testsuite/tests/printer/Ppr009.stderr
new file mode 100644
index 0000000..3aabba4
--- /dev/null
+++ b/testsuite/tests/printer/Ppr009.stderr
@@ -0,0 +1,28 @@
+Ppr009.hs:5:15: error: Not in scope: data constructor ‘Bitstream’
+
+Ppr009.hs:7:7: error:
+    Not in scope: ‘S.concatMap’
+    No module named ‘S’ is imported.
+
+Ppr009.hs:7:27: error:
+    Not in scope: ‘GV.stream’
+    No module named ‘GV’ is imported.
+
+Ppr009.hs:8:7: error:
+    Not in scope: ‘S.sized’
+    No module named ‘S’ is imported.
+
+Ppr009.ppr.hs:4:15: error:
+    Not in scope: data constructor ‘Bitstream’
+
+Ppr009.ppr.hs:6:5: error:
+    Not in scope: ‘S.concatMap’
+    No module named ‘S’ is imported.
+
+Ppr009.ppr.hs:6:25: error:
+    Not in scope: ‘GV.stream’
+    No module named ‘GV’ is imported.
+
+Ppr009.ppr.hs:6:38: error:
+    Not in scope: ‘S.sized’
+    No module named ‘S’ is imported.
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 5086c43..94a85dc 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -6,3 +6,4 @@ test('Ppr005', normal, run_command, ['$MAKE -s --no-print-directory ppr005'])
 test('Ppr006', normal, run_command, ['$MAKE -s --no-print-directory ppr006'])
 test('Ppr007', normal, run_command, ['$MAKE -s --no-print-directory ppr007'])
 test('Ppr008', normal, run_command, ['$MAKE -s --no-print-directory ppr008'])
+test('Ppr009', normal, run_command, ['$MAKE -s --no-print-directory ppr009'])



More information about the ghc-commits mailing list