Parenthesize rank-n contexts in Convert
authorRyan Scott <ryan.gl.scott@gmail.com>
Thu, 5 Jul 2018 12:50:56 +0000 (08:50 -0400)
committerBen Gamari <ben@smart-cactus.org>
Thu, 12 Jul 2018 21:06:11 +0000 (17:06 -0400)
Summary: A simple oversight.

Test Plan: make test TEST=T15324

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15324

Differential Revision: https://phabricator.haskell.org/D4910

(cherry picked from commit 57733978482dc1e566a7d4cd90d4cbbd1315e3b2)

compiler/hsSyn/Convert.hs
testsuite/tests/th/T15324.hs [new file with mode: 0644]
testsuite/tests/th/T15324.stderr [new file with mode: 0644]
testsuite/tests/th/all.T

index 1c3c853..c64cb7c 100644 (file)
@@ -1284,7 +1284,9 @@ cvtTypeKind ty_str ty
                  x'' <- case x' of
                           L _ HsFunTy{}    -> returnL (HsParTy noExt x')
                           L _ HsForAllTy{} -> returnL (HsParTy noExt x')
-                                                                       -- #14646
+                                                               -- #14646
+                          L _ HsQualTy{}   -> returnL (HsParTy noExt x')
+                                                               -- #15324
                           _                -> return x'
                  returnL (HsFunTy noExt x'' y')
              | otherwise ->
diff --git a/testsuite/tests/th/T15324.hs b/testsuite/tests/th/T15324.hs
new file mode 100644 (file)
index 0000000..ea124f4
--- /dev/null
@@ -0,0 +1,7 @@
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TemplateHaskell #-}
+module T15324 where
+
+$([d| f :: forall a. (Show a => a) -> a
+      f _ = undefined
+    |])
diff --git a/testsuite/tests/th/T15324.stderr b/testsuite/tests/th/T15324.stderr
new file mode 100644 (file)
index 0000000..49db9ed
--- /dev/null
@@ -0,0 +1,6 @@
+T15324.hs:(5,3)-(7,6): Splicing declarations
+    [d| f :: forall a. (Show a => a) -> a
+        f _ = undefined |]
+  ======>
+    f :: forall a. (Show a => a) -> a
+    f _ = undefined
index 6209fde..5f756fc 100644 (file)
@@ -416,3 +416,4 @@ test('T14885b', normal, compile, [''])
 test('T14885c', normal, compile, [''])
 test('T15243', normal, compile, ['-dsuppress-uniques'])
 test('T15331', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T15324', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])