diff --git a/compiler/typecheck/TcHsType.lhs b/compiler/typecheck/TcHsType.lhs index 147ce75d019e1f1d3946c858aab3093733d00101..bacb02c34ae97f16c35743d7bbcc8d340500a21b 100644 --- a/compiler/typecheck/TcHsType.lhs +++ b/compiler/typecheck/TcHsType.lhs @@ -604,7 +604,9 @@ tcTyVar name -- Could be a tyvar, a tycon, or a datacon AGlobal (ADataCon dc) | Just tc <- promoteDataCon_maybe dc - -> inst_tycon (mkTyConApp tc) (tyConKind tc) + -> do { data_kinds <- xoptM Opt_DataKinds + ; unless data_kinds $ promotionErr name NoDataKinds + ; inst_tycon (mkTyConApp tc) (tyConKind tc) } | otherwise -> failWithTc (quotes (ppr dc) <+> ptext (sLit "of type") <+> quotes (ppr (dataConUserType dc)) <+> ptext (sLit "is not promotable")) @@ -1474,6 +1476,7 @@ promotionErr name err where reason = case err of FamDataConPE -> ptext (sLit "it comes from a data family instance") + NoDataKinds -> ptext (sLit "Perhaps you intended to use -XDataKinds") _ -> ptext (sLit "it is defined and used in the same recursive group") \end{code} diff --git a/compiler/typecheck/TcRnTypes.lhs b/compiler/typecheck/TcRnTypes.lhs index 0eb1efe509adf8d2e1d6a3175417173c2113c2af..e465883b7b83bbe0b4085de03482b56a68fa3b75 100644 --- a/compiler/typecheck/TcRnTypes.lhs +++ b/compiler/typecheck/TcRnTypes.lhs @@ -593,6 +593,7 @@ data PromotionErr | RecDataConPE -- Data constructor in a reuursive loop -- See Note [ARecDataCon: recusion and promoting data constructors] in TcTyClsDecls + | NoDataKinds -- -XDataKinds not enabled instance Outputable TcTyThing where -- Debugging only ppr (AGlobal g) = pprTyThing g @@ -610,6 +611,7 @@ instance Outputable PromotionErr where ppr TyConPE = text "TyConPE" ppr FamDataConPE = text "FamDataConPE" ppr RecDataConPE = text "RecDataConPE" + ppr NoDataKinds = text "NoDataKinds" pprTcTyThingCategory :: TcTyThing -> SDoc pprTcTyThingCategory (AGlobal thing) = pprTyThingCategory thing @@ -623,6 +625,7 @@ pprPECategory ClassPE = ptext (sLit "Class") pprPECategory TyConPE = ptext (sLit "Type constructor") pprPECategory FamDataConPE = ptext (sLit "Data constructor") pprPECategory RecDataConPE = ptext (sLit "Data constructor") +pprPECategory NoDataKinds = ptext (sLit "Data constructor") \end{code}