[commit: ghc] master: Fix pretty printing of top level SCC pragmas (8ec864d)

git at git.haskell.org git at git.haskell.org
Tue Dec 13 21:24:10 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8ec864d08c09a8aa7aabc4abf30186e5f3995ad4/ghc

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

commit 8ec864d08c09a8aa7aabc4abf30186e5f3995ad4
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date:   Tue Dec 13 14:59:35 2016 -0500

    Fix pretty printing of top level SCC pragmas
    
    Reviewers: austin, alanz, bgamari
    
    Reviewed By: alanz, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2834


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

8ec864d08c09a8aa7aabc4abf30186e5f3995ad4
 compiler/hsSyn/HsBinds.hs         | 6 ++----
 testsuite/tests/printer/Makefile  | 4 ++++
 testsuite/tests/printer/Ppr048.hs | 9 +++++++++
 testsuite/tests/printer/all.T     | 1 +
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/compiler/hsSyn/HsBinds.hs b/compiler/hsSyn/HsBinds.hs
index 1f58bbf..5933df8 100644
--- a/compiler/hsSyn/HsBinds.hs
+++ b/compiler/hsSyn/HsBinds.hs
@@ -975,10 +975,8 @@ ppr_sig (SpecInstSig src ty)
 ppr_sig (MinimalSig _ bf)         = pragBrackets (pprMinimalSig bf)
 ppr_sig (PatSynSig names sig_ty)
   = text "pattern" <+> pprVarSig (map unLoc names) (ppr sig_ty)
-ppr_sig (SCCFunSig _ fn Nothing)
-  = pragBrackets (text "SCC" <+> ppr fn)
-ppr_sig (SCCFunSig src fn (Just str))
-  = pragSrcBrackets  src "{-# SCC#-}" (ppr fn <+> ppr str)
+ppr_sig (SCCFunSig src fn mlabel)
+  = pragSrcBrackets src "{-# SCC" (ppr fn <+> maybe empty ppr mlabel )
 
 instance OutputableBndr name => Outputable (FixitySig name) where
   ppr (FixitySig names fixity) = sep [ppr fixity, pprops]
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index b21419c..7a6bbc5 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -193,3 +193,7 @@ ppr046:
 .PHONY: ppr047
 ppr047:
 	$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Ppr047.hs
+
+.PHONY: ppr048
+ppr048:
+	$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Ppr048.hs
diff --git a/testsuite/tests/printer/Ppr048.hs b/testsuite/tests/printer/Ppr048.hs
new file mode 100644
index 0000000..83322f8
--- /dev/null
+++ b/testsuite/tests/printer/Ppr048.hs
@@ -0,0 +1,9 @@
+module Ppr048 where
+
+{-# SCc foo #-}
+foo :: Int -> Int
+foo       x = x
+
+{-# SCc foo2 "label" #-}
+foo2 :: ()
+foo2 = ()
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 701d678..e0cfcc2 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -45,3 +45,4 @@ test('Ppr044', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr04
 test('Ppr045', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr045'])
 test('Ppr046', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr046'])
 test('Ppr047', expect_fail, run_command, ['$MAKE -s --no-print-directory ppr047'])
+test('Ppr048', ignore_stderr, run_command, ['$MAKE -s --no-print-directory ppr048'])



More information about the ghc-commits mailing list