summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2016-01-15 17:42:02 +0100
committerBen Gamari <ben@smart-cactus.org>2016-01-15 17:42:04 +0100
commit165ae440b6bbf577eabf0b6d422ed6ea3bf949b4 (patch)
tree79f1c08b9c491441cb548dc4b22c514d106ea414 /testsuite/tests/deriving
parent443bf04485f997be2e3a744102605645c54e9d61 (diff)
downloadhaskell-165ae440b6bbf577eabf0b6d422ed6ea3bf949b4.tar.gz
Expand type/kind synonyms in TyVars before deriving-related typechecking
Before, it was possible to have a datatypes such as ``` type ConstantT a b = a newtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deriving Functor data family TFam (f :: * -> *) (a :: *) newtype instance TFam f (ConstantT a f) = TFam (f a) deriving Functor ``` fail to eta-reduce because either (1) a TyVar had a kind synonym that mentioned another TyVar, or (2) an instantiated type was itself a type synonym that mentioned another TyVar. A little bit of tweaking to `expandTypeSynonyms` and applying it before the eta-reduction check in the `deriving` machinery is sufficient to fix this. Fixes #11416. Test Plan: ./validate Reviewers: goldfire, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1772 GHC Trac Issues: #11416
Diffstat (limited to 'testsuite/tests/deriving')
-rw-r--r--testsuite/tests/deriving/should_compile/T11416.hs19
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
2 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/T11416.hs b/testsuite/tests/deriving/should_compile/T11416.hs
new file mode 100644
index 0000000000..4696306107
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11416.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeInType #-}
+module T11416 where
+
+import Data.Kind
+
+type ConstantT a b = a
+
+newtype T f (a :: ConstantT * f) = T (f a)
+ deriving Functor
+
+data family TFam1 (f :: k1) (a :: k2)
+newtype instance TFam1 f (ConstantT a f) = TFam1 (f a)
+ deriving Functor
+
+data family TFam2 (f :: k1) (a :: k2)
+newtype instance TFam2 f (a :: ConstantT * f) = TFam2 (f a)
+ deriving Functor
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index ff26d37d0a..a18a257ff2 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -61,3 +61,4 @@ test('T10524', normal, compile, [''])
test('T11148', normal, run_command,
['$MAKE -s --no-print-directory T11148'])
test('T9968', normal, compile, [''])
+test('T11416', normal, compile, [''])