X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Ftypecheck%2FTcTyClsDecls.lhs;h=95166861ec668c6e0a09546ffc9f5e52a645de73;hb=6a4854eaa266d994ebd0d471614a52b43dd329d9;hp=a99aa2f94a135e4ae8f2aea1aeb1ca4f6924e9cc;hpb=618a704d4c3a1ebcf3b5eba7b16268695f02a369;p=ghc-hetmet.git diff --git a/ghc/compiler/typecheck/TcTyClsDecls.lhs b/ghc/compiler/typecheck/TcTyClsDecls.lhs index a99aa2f..9516686 100644 --- a/ghc/compiler/typecheck/TcTyClsDecls.lhs +++ b/ghc/compiler/typecheck/TcTyClsDecls.lhs @@ -115,7 +115,8 @@ tcTyAndClassDecls boot_names decls = do { -- First check for cyclic type synonysm or classes -- See notes with checkCycleErrs checkCycleErrs decls - + ; mod <- getModule + ; traceTc (text "tcTyAndCl" <+> ppr mod <+> ppr boot_names) ; (syn_tycons, alg_tyclss) <- fixM (\ ~(rec_syn_tycons, rec_alg_tyclss) -> do { let { -- Calculate variances and rec-flag ; (syn_decls, alg_decls) = partition (isSynDecl . unLoc) decls } @@ -371,6 +372,9 @@ tcTyClDecl1 calc_vrcs calc_isrec ; want_generic <- doptM Opt_Generics ; tycon <- fixM (\ tycon -> do { unbox_strict <- doptM Opt_UnboxStrictFields + ; gla_exts <- doptM Opt_GlasgowExts + ; checkTc (gla_exts || h98_syntax) (badGadtDecl tc_name) + ; data_cons <- mappM (addLocM (tcConDecl unbox_strict new_or_data tycon tvs')) cons ; let tc_rhs = case new_or_data of DataType -> mkDataTyConRhs stupid_theta data_cons @@ -384,6 +388,9 @@ tcTyClDecl1 calc_vrcs calc_isrec where arg_vrcs = calc_vrcs tc_name is_rec = calc_isrec tc_name + h98_syntax = case cons of -- All constructors have same shape + L _ (GadtDecl {}) : _ -> False + other -> True tcTyClDecl1 calc_vrcs calc_isrec (ClassDecl {tcdLName = L _ class_name, tcdTyVars = tvs, @@ -643,7 +650,7 @@ checkValidClass cls -- Check that for a generic method, the type of -- the method is sufficiently simple - ; checkTc (dm /= GenDefMeth || validGenericMethodType op_ty) + ; checkTc (dm /= GenDefMeth || validGenericMethodType tau) (badGenericMethodType op_name op_ty) } where @@ -695,7 +702,7 @@ genericMultiParamErr clas badGenericMethodType op op_ty = hang (ptext SLIT("Generic method type is too complex")) 4 (vcat [ppr op <+> dcolon <+> ppr op_ty, - ptext SLIT("You can only use type variables, arrows, and tuples")]) + ptext SLIT("You can only use type variables, arrows, lists, and tuples")]) recSynErr syn_decls = setSrcSpan (getLoc (head sorted_decls)) $ @@ -726,4 +733,8 @@ exRecConErr name badDataConTyCon data_con = hang (ptext SLIT("Data constructor does not return its parent type:")) 2 (ppr data_con) + +badGadtDecl tc_name + = vcat [ ptext SLIT("Illegal generalised algebraic data declaration for") <+> quotes (ppr tc_name) + , nest 2 (parens $ ptext SLIT("Use -fglasgow-exts to allow GADTs")) ] \end{code}