summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-10-25 18:30:55 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2019-10-25 18:31:08 -0400
commit14fd82e354173a9dcef8de2f888086a3dcb99949 (patch)
tree70dc7f6506e41d9d9e606244b1bd964daedfaf63
parentacedfc8b8706a92127c96f487e3e3b1636451704 (diff)
downloadhaskell-wip/T17403.tar.gz
Parenthesize nullary constraint tuples using sigPrec (#17403)wip/T17403
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'])