summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-11-10 11:35:38 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-13 07:08:40 -0500
commit9a939a6cdfb2a1357f9990af329096dff6b5be5c (patch)
tree15cf28073e50d4bbd72ba9de707542567f30dc68
parentb4b19d8990f345f8ae7fde130ba84327353433a9 (diff)
downloadhaskell-9a939a6cdfb2a1357f9990af329096dff6b5be5c.tar.gz
Print name prefixly in the Outputable instance for StandaloneKindSig
Issue #17461 was occurring because the `Outputable` instance for standalone kind signatures was simply calling `ppr` on the name in the kind signature, which does not add parentheses to infix names. The solution is simple: use `pprPrefixOcc` instead. Fixes #17461.
-rw-r--r--compiler/GHC/Hs/Decls.hs3
-rw-r--r--testsuite/tests/th/T17461.hs10
-rw-r--r--testsuite/tests/th/T17461.stderr7
-rw-r--r--testsuite/tests/th/all.T1
4 files changed, 20 insertions, 1 deletions
diff --git a/compiler/GHC/Hs/Decls.hs b/compiler/GHC/Hs/Decls.hs
index f095a3ffeb..2146cc0c07 100644
--- a/compiler/GHC/Hs/Decls.hs
+++ b/compiler/GHC/Hs/Decls.hs
@@ -1471,7 +1471,8 @@ instance OutputableBndrId p
instance OutputableBndrId p
=> Outputable (StandaloneKindSig (GhcPass p)) where
- ppr (StandaloneKindSig _ v ki) = text "type" <+> ppr v <+> text "::" <+> ppr ki
+ ppr (StandaloneKindSig _ v ki)
+ = text "type" <+> pprPrefixOcc (unLoc v) <+> text "::" <+> ppr ki
ppr (XStandaloneKindSig nec) = noExtCon nec
instance Outputable NewOrData where
diff --git a/testsuite/tests/th/T17461.hs b/testsuite/tests/th/T17461.hs
new file mode 100644
index 0000000000..d331a58166
--- /dev/null
+++ b/testsuite/tests/th/T17461.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeOperators #-}
+module T17461 where
+
+import Data.Kind
+
+$([d| type (:+:) :: Type -> Type -> Type
+ type (:+:) = Either
+ |])
diff --git a/testsuite/tests/th/T17461.stderr b/testsuite/tests/th/T17461.stderr
new file mode 100644
index 0000000000..cc730400bf
--- /dev/null
+++ b/testsuite/tests/th/T17461.stderr
@@ -0,0 +1,7 @@
+T17461.hs:(8,3)-(10,6): Splicing declarations
+ [d| type (:+:) :: Type -> Type -> Type
+
+ type (:+:) = Either |]
+ ======>
+ type (:+:) :: Type -> Type -> Type
+ type (:+:) = Either
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index a75703dd83..b63b0ceb01 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -491,3 +491,4 @@ test('T17380', normal, compile_fail, [''])
test('T17394', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T17379a', normal, compile_fail, [''])
test('T17379b', normal, compile_fail, [''])
+test('T17461', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])