summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer/Ppr012.hs
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2016-11-08 21:37:48 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2016-12-07 21:31:13 +0200
commit499e43824bda967546ebf95ee33ec1f84a114a7c (patch)
tree58b313d734cfba014395ea5876db48e8400296a8 /testsuite/tests/printer/Ppr012.hs
parent83d69dca896c7df1f2a36268d5b45c9283985ebf (diff)
downloadhaskell-499e43824bda967546ebf95ee33ec1f84a114a7c.tar.gz
Add HsSyn prettyprinter tests
Summary: Add prettyprinter tests, which take a file, parse it, pretty print it, re-parse the pretty printed version and then compare the original and new ASTs (ignoring locations) Updates haddock submodule to match the AST changes. There are three issues outstanding 1. Extra parens around a context are not reproduced. This will require an AST change and will be done in a separate patch. 2. Currently if an `HsTickPragma` is found, this is not pretty-printed, to prevent noise in the output. I am not sure what the desired behaviour in this case is, so have left it as before. Test Ppr047 is marked as expected fail for this. 3. Apart from in a context, the ParsedSource AST keeps all the parens from the original source. Something is happening in the renamer to remove the parens around visible type application, causing T12530 to fail, as the dumped splice decl is after the renamer. This needs to be fixed by keeping the parens, but I do not know where they are being removed. I have amended the test to pass, by removing the parens in the expected output. Test Plan: ./validate Reviewers: goldfire, mpickering, simonpj, bgamari, austin Reviewed By: simonpj, bgamari Subscribers: simonpj, goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2752 GHC Trac Issues: #3384
Diffstat (limited to 'testsuite/tests/printer/Ppr012.hs')
-rw-r--r--testsuite/tests/printer/Ppr012.hs42
1 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/tests/printer/Ppr012.hs b/testsuite/tests/printer/Ppr012.hs
new file mode 100644
index 0000000000..b34b1470f4
--- /dev/null
+++ b/testsuite/tests/printer/Ppr012.hs
@@ -0,0 +1,42 @@
+{-# OPTIONS -O -ddump-stranal #-}
+
+module Dead1(foo) where
+
+foo :: Int -> Int
+foo n = baz (n+1) (bar1 n)
+
+{-# NOINLINE bar1 #-}
+bar1 n = 1 + bar n
+
+bar :: Int -> Int
+{-# NOINLINE bar #-}
+{-# RULES
+"bar/foo" forall n. bar (foo n) = n
+ #-}
+bar n = n-1
+
+baz :: Int -> Int -> Int
+{-# INLINE [0] baz #-}
+baz m n = m
+
+
+{- Ronam writes (Feb08)
+
+ Note that bar becomes dead as soon as baz gets inlined. But strangely,
+ the simplifier only deletes it after full laziness and CSE. That is, it
+ is not deleted in the phase in which baz gets inlined. In fact, it is
+ still there after w/w and the subsequent simplifier run. It gets deleted
+ immediately if I comment out the rule.
+
+ I stumbled over this when I removed one simplifier run after SpecConstr
+ (at the moment, it runs twice at the end but I don't think that should
+ be necessary). With this change, the original version of a specialised
+ loop (the one with the rules) is not longer deleted even if it isn't
+ used any more. I'll reenable the second simplifier run for now but
+ should this really be necessary?
+
+No, it should not be necessary. A refactoring in OccurAnal makes
+this work right. Look at the simplifier output just before strictness
+analysis; there should be a binding for 'foo', but for nothing else.
+
+-}