summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-10-25 18:30:55 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-27 11:36:17 -0400
commitfa0d48094afb8025bd85356a5d62d2bc96eb2124 (patch)
tree8bcee1c7d0b959b9929ed425508b113624db16a7
parent7d80f8b5b529a63771d2f9771d5161825721f683 (diff)
downloadhaskell-fa0d48094afb8025bd85356a5d62d2bc96eb2124.tar.gz
Parenthesize nullary constraint tuples using sigPrec (#17403)
We were using `appPrec`, not `sigPrec`, as the precedence when determining whether or not to parenthesize `() :: Constraint`, which lead to the parentheses being omitted in function contexts like `(() :: Constraint) => String`. Easily fixed. Fixes #17403.
-rw-r--r--compiler/iface/IfaceType.hs2
-rw-r--r--testsuite/tests/ghci/scripts/T17403.hs8
-rw-r--r--testsuite/tests/ghci/scripts/T17403.script2
-rw-r--r--testsuite/tests/ghci/scripts/T17403.stdout1
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
5 files changed, 13 insertions, 1 deletions
diff --git a/compiler/iface/IfaceType.hs b/compiler/iface/IfaceType.hs
index acf116169e..2ca9319b34 100644
--- a/compiler/iface/IfaceType.hs
+++ b/compiler/iface/IfaceType.hs
@@ -1467,7 +1467,7 @@ pprSum _arity is_promoted args
pprTuple :: PprPrec -> TupleSort -> PromotionFlag -> IfaceAppArgs -> SDoc
pprTuple ctxt_prec ConstraintTuple NotPromoted IA_Nil
- = maybeParen ctxt_prec appPrec $
+ = maybeParen ctxt_prec sigPrec $
text "() :: Constraint"
-- All promoted constructors have kind arguments
diff --git a/testsuite/tests/ghci/scripts/T17403.hs b/testsuite/tests/ghci/scripts/T17403.hs
new file mode 100644
index 0000000000..5112ffa236
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17403.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE ConstraintKinds #-}
+{-# LANGUAGE KindSignatures #-}
+module T17403 where
+
+import Data.Kind
+
+f :: (() :: Constraint) => String
+f = "hello world"
diff --git a/testsuite/tests/ghci/scripts/T17403.script b/testsuite/tests/ghci/scripts/T17403.script
new file mode 100644
index 0000000000..ad0f9cd83f
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17403.script
@@ -0,0 +1,2 @@
+:load T17403
+:type +v f
diff --git a/testsuite/tests/ghci/scripts/T17403.stdout b/testsuite/tests/ghci/scripts/T17403.stdout
new file mode 100644
index 0000000000..c543c3d0e5
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17403.stdout
@@ -0,0 +1 @@
+f :: (() :: Constraint) => String
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 96ca2eba24..ede2805d10 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -313,3 +313,4 @@ test('T15546', normal, ghci_script, ['T15546.script'])
test('T16876', normal, ghci_script, ['T16876.script'])
test('T17345', normal, ghci_script, ['T17345.script'])
test('T17384', normal, ghci_script, ['T17384.script'])
+test('T17403', normal, ghci_script, ['T17403.script'])