X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcPat.lhs;h=82ac5e3596a53c1558c6800ed3f58f2b7b09a5fd;hb=cc9a63c2552d74abc1fefae647aeba062ea76b71;hp=c6caa5451724f2db4a6dea8910cc9212d3516d36;hpb=cab7dec5854951416c56e64cda66a4bd96aeaa0f;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcPat.lhs b/compiler/typecheck/TcPat.lhs index c6caa54..82ac5e3 100644 --- a/compiler/typecheck/TcPat.lhs +++ b/compiler/typecheck/TcPat.lhs @@ -37,6 +37,7 @@ import TyCon import DataCon import PrelNames import BasicTypes hiding (SuccessFlag(..)) +import DynFlags ( DynFlag( Opt_GADTs ) ) import SrcLoc import ErrUtils import Util @@ -427,7 +428,7 @@ tc_pat pstate (orig@(ViewPat expr pat _)) overall_pat_ty thing_inside tc_pat pstate (SigPatIn pat sig_ty) pat_ty thing_inside = do { (inner_ty, tv_binds, coi) <- tcPatSig (patSigCtxt pstate) sig_ty pat_ty - ; unless (isIdentityCoercion coi) $ + ; unless (isIdentityCoI coi) $ failWithTc (badSigPat pat_ty) ; (pat', tvs, res) <- tcExtendTyVarEnv2 tv_binds $ tc_lpat pat inner_ty pstate thing_inside @@ -670,6 +671,12 @@ tcConPat pstate con_span data_con tycon pat_ty arg_pats thing_inside pstate' | no_equalities = pstate | otherwise = pstate { pat_eqs = True } + ; gadts_on <- doptM Opt_GADTs + ; checkTc (no_equalities || gadts_on) + (ptext (sLit "A pattern match on a GADT requires -XGADTs")) + -- Trac #2905 decided that a *pattern-match* of a GADT + -- should require the GADT language flag + ; unless no_equalities $ checkTc (isRigidTy pat_ty) $ nonRigidMatch (pat_ctxt pstate) data_con @@ -702,7 +709,7 @@ tcConPat pstate con_span data_con tycon pat_ty arg_pats thing_inside ; (_, freshTvs, subst) <- tcInstTyVars (tyConTyVars tycon) ; let instTys' = substTys subst instTys ; cois <- boxyUnifyList instTys' scrutinee_arg_tys - ; let coi = if isIdentityCoercion coi1 + ; let coi = if isIdentityCoI coi1 then -- pat_ty was splittable -- => boxyUnifyList had real work to do mkTyConAppCoI fam_tycon instTys' cois