diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-08-17 19:03:23 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-17 19:22:00 -0400 |
commit | 9c21b2fd041f19ad02f1c1d530a3f9cbf092c622 (patch) | |
tree | ecb0343f6a0a906fe4745f892383a4ce7fa81921 /compiler/typecheck | |
parent | ae4415b9487d24942aa0e91052d4b897a3cf2f2e (diff) | |
download | haskell-9c21b2fd041f19ad02f1c1d530a3f9cbf092c622.tar.gz |
Fix #13571 by adding an extension flag check
Test case: indexed-types/should_fail/T13571
Diffstat (limited to 'compiler/typecheck')
-rw-r--r-- | compiler/typecheck/TcTyClsDecls.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs index 91536e5d23..237f59f5b9 100644 --- a/compiler/typecheck/TcTyClsDecls.hs +++ b/compiler/typecheck/TcTyClsDecls.hs @@ -1951,6 +1951,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info { traceTc "open type family:" (ppr tc_name) ; checkFamFlag tc_name ; inj' <- tcInjectivity binders inj + ; checkResultSigFlag tc_name sig -- check after injectivity for better errors ; let tycon = mkFamilyTyCon tc_name binders res_kind (resultVariableName sig) OpenSynFamilyTyCon parent inj' @@ -1968,6 +1969,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info ; return (inj', binders, res_kind) } ; checkFamFlag tc_name -- make sure we have -XTypeFamilies + ; checkResultSigFlag tc_name sig -- If Nothing, this is an abstract family in a hs-boot file; -- but eqns might be empty in the Just case as well @@ -3707,6 +3709,14 @@ checkFamFlag tc_name err_msg = hang (text "Illegal family declaration for" <+> quotes (ppr tc_name)) 2 (text "Enable TypeFamilies to allow indexed type families") +checkResultSigFlag :: Name -> FamilyResultSig GhcRn -> TcM () +checkResultSigFlag tc_name (TyVarSig _ tvb) + = do { ty_fam_deps <- xoptM LangExt.TypeFamilyDependencies + ; checkTc ty_fam_deps $ + hang (text "Illegal result type variable" <+> ppr tvb <+> text "for" <+> quotes (ppr tc_name)) + 2 (text "Enable TypeFamilyDependencies to allow result variable names") } +checkResultSigFlag _ _ = return () -- other cases OK + {- Note [Class method constraints] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Haskell 2010 is supposed to reject |