[commit: ghc] master: Fix #14390 by making toIfaceTyCon aware of equality (85aa1f4)

git at git.haskell.org git at git.haskell.org
Mon Oct 30 01:51:33 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/85aa1f4253163985fe07d172f8da73b784bb7b4b/ghc

>---------------------------------------------------------------

commit 85aa1f4253163985fe07d172f8da73b784bb7b4b
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sun Oct 29 20:48:19 2017 -0400

    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


>---------------------------------------------------------------

85aa1f4253163985fe07d172f8da73b784bb7b4b
 compiler/iface/ToIface.hs                           | 6 ++++++
 testsuite/tests/typecheck/should_fail/T14390.hs     | 4 ++++
 testsuite/tests/typecheck/should_fail/T14390.stderr | 5 +++++
 testsuite/tests/typecheck/should_fail/all.T         | 1 +
 4 files changed, 16 insertions(+)

diff --git a/compiler/iface/ToIface.hs b/compiler/iface/ToIface.hs
index 9eceb6d..6f71af5 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 0000000..5360be7
--- /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 0000000..f94bf40
--- /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 1aa23c4..ca0264b 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, [''])



More information about the ghc-commits mailing list