summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/typecheck/TcTyClsDecls.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T2
2 files changed, 9 insertions, 3 deletions
diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs
index 7fec6f4dd3..64798c94d7 100644
--- a/compiler/typecheck/TcTyClsDecls.hs
+++ b/compiler/typecheck/TcTyClsDecls.hs
@@ -3412,8 +3412,14 @@ checkValidTyCon tc
| Just fam_flav <- famTyConFlav_maybe tc
-> case fam_flav of
{ ClosedSynFamilyTyCon (Just ax)
- -> tcAddClosedTypeFamilyDeclCtxt tc $
- checkValidCoAxiom ax
+ -> tcAddClosedTypeFamilyDeclCtxt tc $ do
+ -- Ensure that the TyCon in the equation matches
+ -- the tycon of the class head. See #17633.
+ checkTc (co_ax_tc tc == tc)
+ text "The type constructor" <+> ppr (co_ax_tc tc) <+>
+ text "in the LHS of the equation must match the family" <+>
+ text "name" <+> ppr tc <> text "."
+ checkValidCoAxiom tc ax
; ClosedSynFamilyTyCon Nothing -> return ()
; AbstractClosedSynFamilyTyCon ->
do { hsBoot <- tcIsHsBootOrSig
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 7c3763a364..0ee1d6c386 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -549,4 +549,4 @@ test('T17213', [extra_files(['T17213a.hs'])], multimod_compile_fail, ['T17213',
test('T17355', normal, compile_fail, [''])
test('T17360', normal, compile_fail, [''])
test('T17563', normal, compile_fail, [''])
-test('T17633', expect_broken(17633), compile_fail, [''])
+test('T17633', normal, compile_fail, [''])