diff options
-rw-r--r-- | compiler/typecheck/FamInst.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T12430.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T12430.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/all.T | 1 |
4 files changed, 18 insertions, 0 deletions
diff --git a/compiler/typecheck/FamInst.hs b/compiler/typecheck/FamInst.hs index dc6eab8081..8f1f7ba5f6 100644 --- a/compiler/typecheck/FamInst.hs +++ b/compiler/typecheck/FamInst.hs @@ -792,6 +792,9 @@ injTyVarsOfType :: TcTauType -> TcTyVarSet -- E.g. Suppose F is injective in its second arg, but not its first -- then injVarOfType (Either a (F [b] (a,c))) = {a,c} -- Determining the overall type determines a,c but not b. +injTyVarsOfType ty + | Just ty' <- coreView ty -- #12430 + = injTyVarsOfType ty' injTyVarsOfType (TyVarTy v) = unitVarSet v `unionVarSet` injTyVarsOfType (tyVarKind v) injTyVarsOfType (TyConApp tc tys) diff --git a/testsuite/tests/typecheck/should_fail/T12430.hs b/testsuite/tests/typecheck/should_fail/T12430.hs new file mode 100644 index 0000000000..03cded2b44 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T12430.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TypeFamilyDependencies #-} +module T12430 where + +type C a = Int +type family F x = y | y -> x where + F x = C x diff --git a/testsuite/tests/typecheck/should_fail/T12430.stderr b/testsuite/tests/typecheck/should_fail/T12430.stderr new file mode 100644 index 0000000000..c3d9446197 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T12430.stderr @@ -0,0 +1,8 @@ + +T12430.hs:6:3: error: + • Type family equation violates injectivity annotation. + Type variable ‘x’ cannot be inferred from the right-hand side. + In the type family equation: + F x = C x -- Defined at T12430.hs:6:3 + • In the equations for closed type family ‘F’ + In the type family declaration for ‘F’ diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 274dcc669e..501c5e1651 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -413,6 +413,7 @@ test('T12177', normal, compile_fail, ['']) test('T12406', normal, compile_fail, ['']) test('T12170a', normal, compile_fail, ['']) test('T12124', normal, compile_fail, ['']) +test('T12430', normal, compile_fail, ['']) test('T12589', normal, compile_fail, ['']) test('T12529', normal, compile_fail, ['']) test('T12563', normal, compile_fail, ['']) |