summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-10-29 20:48:19 -0400
committerBen Gamari <ben@smart-cactus.org>2017-10-29 21:51:05 -0400
commit85aa1f4253163985fe07d172f8da73b784bb7b4b (patch)
treead42e09d5d24a4d8e199ab35b34f29ef4190a3d4
parent7673561555ae354fd9eed8de1e57c681906e2d49 (diff)
downloadhaskell-85aa1f4253163985fe07d172f8da73b784bb7b4b.tar.gz
Fix #14390 by making toIfaceTyCon aware of equality
GHC was panicking when pretty-printing a heterogeneous equality type constructor (#14390) because the function which produced the type constructor, `toIfaceTyCon`, wasn't attaching the appropriate `IfaceTyConSort` for equality type constructors, which is `IfaceEqualityTyCon`. This is fixed easily enough. Test Plan: make test TEST=T14390 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #14390 Differential Revision: https://phabricator.haskell.org/D4132
-rw-r--r--compiler/iface/ToIface.hs6
-rw-r--r--testsuite/tests/typecheck/should_fail/T14390.hs4
-rw-r--r--testsuite/tests/typecheck/should_fail/T14390.stderr5
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
4 files changed, 16 insertions, 0 deletions
diff --git a/compiler/iface/ToIface.hs b/compiler/iface/ToIface.hs
index 9eceb6d750..6f71af516e 100644
--- a/compiler/iface/ToIface.hs
+++ b/compiler/iface/ToIface.hs
@@ -195,6 +195,12 @@ toIfaceTyCon tc
| isUnboxedSumTyCon tc
, Just cons <- isDataSumTyCon_maybe tc = IfaceSumTyCon (length cons)
+ | tyConName tc == eqTyConName || tc == eqPrimTyCon
+ = IfaceEqualityTyCon True
+
+ | tc `elem` [heqTyCon, eqReprPrimTyCon]
+ = IfaceEqualityTyCon False
+
| otherwise = IfaceNormalTyCon
diff --git a/testsuite/tests/typecheck/should_fail/T14390.hs b/testsuite/tests/typecheck/should_fail/T14390.hs
new file mode 100644
index 0000000000..5360be714c
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14390.hs
@@ -0,0 +1,4 @@
+module T14390 where
+
+import Data.Type.Equality
+instance (~~) Int Int
diff --git a/testsuite/tests/typecheck/should_fail/T14390.stderr b/testsuite/tests/typecheck/should_fail/T14390.stderr
new file mode 100644
index 0000000000..f94bf40700
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14390.stderr
@@ -0,0 +1,5 @@
+
+T14390.hs:4:10: error:
+ • Illegal instance declaration for ‘(Int :: *) ~~ (Int :: *)’
+ Manual instances of this class are not permitted.
+ • In the instance declaration for ‘(~~) Int Int’
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 1aa23c4945..ca0264b773 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -460,3 +460,4 @@ test('T13929', normal, compile_fail, [''])
test('T14232', normal, compile_fail, [''])
test('T14325', normal, compile_fail, [''])
test('T14350', normal, compile_fail, [''])
+test('T14390', normal, compile_fail, [''])