summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-12-04 12:08:37 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2015-12-04 14:21:32 +0000
commit1160dc516f8b27249d819665883409ee270a743f (patch)
treead74db7f08839cbfb315e18dada1c416ad6d0dcb /testsuite/tests
parent822141b95174f068872fd4e491da764139ce626f (diff)
downloadhaskell-1160dc516f8b27249d819665883409ee270a743f.tar.gz
Fix egregious error in eta-reduction of data families
This terrible and long-standing bug was shown up by Trac #11148. We are trying to eta-reduce a data family instance, so that we can then derive Functor or Generic. But we were assuming, for absolutely not reason whatsoever, that the type variables were lined up in a convenient order. The fact that it ever worked was a fluke. This patch fixes it properly. Main change is in eta_reduce in TcInstDcls.tcDataFamInstDecl
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/deriving/should_compile/Makefile10
-rw-r--r--testsuite/tests/deriving/should_compile/T11148.hs11
-rw-r--r--testsuite/tests/deriving/should_compile/all.T2
3 files changed, 22 insertions, 1 deletions
diff --git a/testsuite/tests/deriving/should_compile/Makefile b/testsuite/tests/deriving/should_compile/Makefile
index f9e816f13f..581aabbce0 100644
--- a/testsuite/tests/deriving/should_compile/Makefile
+++ b/testsuite/tests/deriving/should_compile/Makefile
@@ -2,7 +2,15 @@ TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
-.PHONY: T1133
+.PHONY: T1133 T11148
+
+T11148:
+ $(RM) T11148.hi T11148.o
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c -dunique-increment=-1 T11148.hs
+ # Set the unique-increment to '-1' to trigger the bug
+ # This has to be done on the command line;
+ # an OPTIONS_GHC pragma does not do it
+
T1133:
'$(TEST_HC)' $(TEST_HC_OPTS) -c T1133.hs-boot
'$(TEST_HC)' $(TEST_HC_OPTS) -c T1133a.hs
diff --git a/testsuite/tests/deriving/should_compile/T11148.hs b/testsuite/tests/deriving/should_compile/T11148.hs
new file mode 100644
index 0000000000..5e505beb31
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T11148.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE DeriveFunctor #-}
+{-# LANGUAGE FlexibleInstances #-}
+
+module T11148 where
+
+data family G a b c d
+data instance G Int b Float d = G deriving Functor
+
+data family H a b c d
+data instance H [b] b d c = H deriving Functor
diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T
index 9ffa07df3d..ac41df4a39 100644
--- a/testsuite/tests/deriving/should_compile/all.T
+++ b/testsuite/tests/deriving/should_compile/all.T
@@ -56,3 +56,5 @@ test('T4896', normal, compile, [''])
test('T7947', extra_clean(['T7947a.o', 'T7947a.hi', 'T7947b.o', 'T7947b.hi']), multimod_compile, ['T7947', '-v0'])
test('T10561', normal, compile_fail, [''])
test('T10487', extra_clean(['T10487_M.o', 'T10487_M.hi']), multimod_compile, ['T10487', '-v0'])
+test('T11148', normal, run_command,
+ ['$MAKE -s --no-print-directory T11148'])