summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2016-05-11 15:57:24 +0200
committerBen Gamari <ben@smart-cactus.org>2016-05-12 15:39:30 +0200
commite53f2180e89652c72e51ffa614c56294ba67cf37 (patch)
treed55760338985aebb5c3ba879e32b0ec9d825b6de /testsuite
parentc079de3c43704ea88f592e441389e520313e30ad (diff)
downloadhaskell-e53f2180e89652c72e51ffa614c56294ba67cf37.tar.gz
Fix deriveTyData's kind unification when two kind variables are unified
When `deriveTyData` attempts to unify two kind variables (which can happen if both the typeclass and the datatype are poly-kinded), it mistakenly adds an extra mapping to its substitution which causes the unification to fail when applying the substitution. This can be prevented by checking both the domain and the range of the original substitution to see which kind variables shouldn't be put into the domain of the substitution. A more in-depth explanation is included in `Note [Unification of two kind variables in deriving]`. Fixes #11837. Test Plan: ./validate Reviewers: simonpj, hvr, goldfire, niteria, austin, bgamari Reviewed By: bgamari Subscribers: niteria, thomie Differential Revision: https://phabricator.haskell.org/D2117 GHC Trac Issues: #11837
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/deriving/should_compile/T11837.hs9
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
2 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/T11837.hs b/testsuite/tests/deriving/should_compile/T11837.hs
new file mode 100644
index 0000000000..917f9cb5cb
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11837.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE PolyKinds #-}
+module T11837 where
+
+class Category (cat :: k -> k -> *) where
+ catId :: cat a a
+ catComp :: cat b c -> cat a b -> cat a c
+
+newtype T (c :: k -> k -> *) a b = MkT (c a b) deriving Category
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index 07242ec694..9017687b07 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -70,3 +70,4 @@ test('T11732a', normal, compile, [''])
test('T11732b', normal, compile, [''])
test('T11732c', normal, compile, [''])
test('T11833', normal, compile, [''])
+test('T11837', normal, compile, [''])