[commit: ghc] ghc-8.0: Fix #11754 by adding an additional check. (91a8e92)
git at git.haskell.org
git at git.haskell.org
Mon Mar 28 11:37:21 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/91a8e92606890ca191ca7227b11a95c9c76cb428/ghc
>---------------------------------------------------------------
commit 91a8e92606890ca191ca7227b11a95c9c76cb428
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date: Fri Mar 25 15:11:24 2016 -0400
Fix #11754 by adding an additional check.
This was just plain wrong previously.
Test case: typecheck/should_compile/T11754
(cherry picked from commit 4da8e73d5235b0000ae27aa8ff8438a3687b6e9c)
>---------------------------------------------------------------
91a8e92606890ca191ca7227b11a95c9c76cb428
compiler/types/OptCoercion.hs | 7 +++---
testsuite/tests/typecheck/should_compile/T11754.hs | 28 ++++++++++++++++++++++
testsuite/tests/typecheck/should_compile/all.T | 1 +
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs
index fb6c68e..e39f0aa 100644
--- a/compiler/types/OptCoercion.hs
+++ b/compiler/types/OptCoercion.hs
@@ -874,10 +874,11 @@ etaTyConAppCo_maybe tc (TyConAppCo _ tc2 cos2)
etaTyConAppCo_maybe tc co
| mightBeUnsaturatedTyCon tc
- , Pair ty1 ty2 <- coercionKind co
- , Just (tc1, tys1) <- splitTyConApp_maybe ty1
- , Just (tc2, tys2) <- splitTyConApp_maybe ty2
+ , (Pair ty1 ty2, r) <- coercionKindRole co
+ , Just (tc1, tys1) <- splitTyConApp_maybe ty1
+ , Just (tc2, tys2) <- splitTyConApp_maybe ty2
, tc1 == tc2
+ , isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep
, let n = length tys1
= ASSERT( tc == tc1 )
ASSERT( n == length tys2 )
diff --git a/testsuite/tests/typecheck/should_compile/T11754.hs b/testsuite/tests/typecheck/should_compile/T11754.hs
new file mode 100644
index 0000000..248be2b
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T11754.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE TypeOperators, UndecidableSuperClasses, KindSignatures,
+TypeFamilies, FlexibleContexts #-}
+
+module T11754 where
+
+import Data.Kind
+import Data.Void
+
+newtype K a x = K a
+newtype I x = I x
+
+data (f + g) x = L (f x) | R (g x)
+data (f × g) x = f x :×: g x
+
+class Differentiable (D f) => Differentiable f where
+ type D (f :: Type -> Type) :: Type -> Type
+
+instance Differentiable (K a) where
+ type D (K a) = K Void
+
+instance Differentiable I where
+ type D I = K ()
+
+instance (Differentiable f₁, Differentiable f₂) => Differentiable (f₁ + f₂) where
+ type D (f₁ + f₂) = D f₁ + D f₂
+
+instance (Differentiable f₁, Differentiable f₂) => Differentiable (f₁ × f₂) where
+ type D (f₁ × f₂) = (D f₁ × f₂) + (f₁ × D f₂)
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index f1403da..158de37 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -508,3 +508,4 @@ test('T11608', normal, compile, [''])
test('T11401', normal, compile, [''])
test('T11699', normal, compile, [''])
test('T11512', normal, compile, [''])
+test('T11754', normal, compile, [''])
More information about the ghc-commits
mailing list