diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-04-19 12:36:42 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-04-19 13:18:14 -0400 |
commit | b08a6d75e0440f33260bea5319b8c3f871b42f6e (patch) | |
tree | eeae0a52bc64aac7a1a9e2d83e25053f0b87e243 /testsuite/tests/generics | |
parent | cac8be611e7e80ed80e24b15faac9e1ac0a07247 (diff) | |
download | haskell-b08a6d75e0440f33260bea5319b8c3f871b42f6e.tar.gz |
Fix #15012 with a well-placed use of Any
Previously, derived `Generic1` instances could have associated `Rep1`
type family instances with unbound variables, such as in the following
example:
```lang=haskell
data T a = MkT (FakeOut a) deriving Generic1
type FakeOut a = Int
==>
instance Generic1 T where
type Rep1 T = ... (Rec0 (FakeOut a))
```
Yikes! To avoid this, we simply map the last type variable in a
derived `Generic1` instance to `Any`.
Test Plan: make test TEST=T15012
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: simonpj, thomie, carter
GHC Trac Issues: #15012
Differential Revision: https://phabricator.haskell.org/D4602
Diffstat (limited to 'testsuite/tests/generics')
-rw-r--r-- | testsuite/tests/generics/Makefile | 5 | ||||
-rw-r--r-- | testsuite/tests/generics/T15012.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/generics/T15012a.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/generics/all.T | 2 |
4 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/generics/Makefile b/testsuite/tests/generics/Makefile index 9a36a1c5fe..69a5802b96 100644 --- a/testsuite/tests/generics/Makefile +++ b/testsuite/tests/generics/Makefile @@ -1,3 +1,8 @@ TOP=../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk + +T15012: + $(RM) T15012.hi T15012.o T15012a.hi T15012a.o + '$(TEST_HC)' $(TEST_HC_OPTS) -c T15012a.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -c T15012.hs diff --git a/testsuite/tests/generics/T15012.hs b/testsuite/tests/generics/T15012.hs new file mode 100644 index 0000000000..388eddc0ed --- /dev/null +++ b/testsuite/tests/generics/T15012.hs @@ -0,0 +1,7 @@ +module T15012 where + +import GHC.Generics +import T15012a + +blah :: IO () +blah = print $ from1 $ TyFamily 1 2 diff --git a/testsuite/tests/generics/T15012a.hs b/testsuite/tests/generics/T15012a.hs new file mode 100644 index 0000000000..5109ea08f0 --- /dev/null +++ b/testsuite/tests/generics/T15012a.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE TypeFamilies #-} +module T15012a where + +import GHC.Generics + +type FakeOut a = Int + +data family TyFamily y z +data instance TyFamily a b = TyFamily Int (FakeOut b) + deriving Generic1 diff --git a/testsuite/tests/generics/all.T b/testsuite/tests/generics/all.T index 1d4aeaee38..f127f7895f 100644 --- a/testsuite/tests/generics/all.T +++ b/testsuite/tests/generics/all.T @@ -43,3 +43,5 @@ test('T10361a', normal, compile, ['']) test('T10361b', normal, compile, ['']) test('T11358', normal, compile_and_run, ['']) test('T12220', normal, compile, ['']) +test('T15012', [extra_files(['T15012.hs', 'T15012a.hs'])], run_command, + ['$MAKE -s --no-print-directory T15012']) |