summaryrefslogtreecommitdiff
path: root/testsuite/tests/th
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-10-15 13:49:11 -0400
committerBen Gamari <ben@smart-cactus.org>2018-10-15 17:59:20 -0400
commit02b2116e458357e87718e7378a80579a7021e2a7 (patch)
tree1849ba48aa90364997602ea5e8a175ef819bc9fa /testsuite/tests/th
parentc5b477c29127d8375b3f23d37f877278b52547f6 (diff)
downloadhaskell-02b2116e458357e87718e7378a80579a7021e2a7.tar.gz
Fix #15738 by defining (and using) parenthesizeHsContext
With `QuantifiedConstraints`, `forall`s can appear in more nested positions than they could before, but `Convert` and the TH pretty-printer were failing to take this into account. On the `Convert` side, this is fixed by using a `parenthesizeHsContext` to parenthesize singleton quantified constraints that appear to the left of a `=>`. (A similar fix is applied to the TH pretty-printer.) Test Plan: make test TEST=T15738 Reviewers: goldfire, bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15738 Differential Revision: https://phabricator.haskell.org/D5222
Diffstat (limited to 'testsuite/tests/th')
-rw-r--r--testsuite/tests/th/T15738.hs13
-rw-r--r--testsuite/tests/th/T15738.stderr11
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/th/T15738.hs b/testsuite/tests/th/T15738.hs
new file mode 100644
index 0000000000..4bc2d45686
--- /dev/null
+++ b/testsuite/tests/th/T15738.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE QuantifiedConstraints #-}
+{-# LANGUAGE TemplateHaskell #-}
+module T15738 where
+
+import Language.Haskell.TH
+import System.IO
+
+data Foo x = MkFoo x
+
+$(do d <- [d| f :: (forall a. Eq (Foo a)) => Foo x -> Foo x -> Bool
+ f = (==) |]
+ runIO $ hPutStrLn stderr $ pprint d
+ pure d)
diff --git a/testsuite/tests/th/T15738.stderr b/testsuite/tests/th/T15738.stderr
new file mode 100644
index 0000000000..57a2db5832
--- /dev/null
+++ b/testsuite/tests/th/T15738.stderr
@@ -0,0 +1,11 @@
+f_0 :: (forall a_1 . GHC.Classes.Eq (T15738.Foo a_1)) =>
+ T15738.Foo x_2 -> T15738.Foo x_2 -> GHC.Types.Bool
+f_0 = (GHC.Classes.==)
+T15738.hs:(10,3)-(13,11): Splicing declarations
+ do d <- [d| f :: (forall a. Eq (Foo a)) => Foo x -> Foo x -> Bool
+ f = (==) |]
+ runIO $ hPutStrLn stderr $ pprint d
+ pure d
+ ======>
+ f :: (forall a. Eq (Foo a)) => Foo x -> Foo x -> Bool
+ f = (==)
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 249493e0ff..df114b57bf 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -438,3 +438,4 @@ test('TH_implicitParamsErr3', normal, compile_fail, ['-v0 -dsuppress-uniques'])
test('TH_recursiveDo', normal, compile_and_run, ['-v0 -dsuppress-uniques'])
test('T15481', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('TH_recover_warns', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T15738', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])