From: simonpj Date: Sat, 16 Apr 2005 22:45:17 +0000 (+0000) Subject: [project @ 2005-04-16 22:45:17 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~728 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=bb551326b9a88fd389d6068b8aceda5310c1beb4;p=ghc-hetmet.git [project @ 2005-04-16 22:45:17 by simonpj] Improve location info for kind errors; may make some tests change their output --- diff --git a/ghc/compiler/typecheck/TcHsType.lhs b/ghc/compiler/typecheck/TcHsType.lhs index fb9f0db..6686899 100644 --- a/ghc/compiler/typecheck/TcHsType.lhs +++ b/ghc/compiler/typecheck/TcHsType.lhs @@ -39,9 +39,8 @@ import TcUnify ( unifyFunKind, checkExpectedKind ) import TcType ( Type, PredType(..), ThetaType, MetaDetails(Flexi), hoistForAllTys, TcType, TcTyVar, TcKind, TcThetaType, TcTauType, - mkFunTy, - mkSigmaTy, mkPredTy, mkGenTyConApp, mkTyConApp, mkAppTys, - typeKind ) + mkFunTy, mkSigmaTy, mkPredTy, mkGenTyConApp, + mkTyConApp, mkAppTys, typeKind ) import Kind ( Kind, isLiftedTypeKind, liftedTypeKind, ubxTupleKind, openTypeKind, argTypeKind, splitKindFunTys ) import Id ( idName ) @@ -238,9 +237,13 @@ kcCheckHsType :: LHsType Name -> TcKind -> TcM (LHsType Name) -- with OpenTypeKind, because it gives better error messages kcCheckHsType (L span ty) exp_kind = setSrcSpan span $ - kc_hs_type ty `thenM` \ (ty', act_kind) -> - checkExpectedKind ty act_kind exp_kind `thenM_` - returnM (L span ty') + do { (ty', act_kind) <- addErrCtxt (typeCtxt ty) $ + kc_hs_type ty + -- Add the context round the inner check only + -- because checkExpectedKind already mentions + -- 'ty' by name in any error message + ; checkExpectedKind ty act_kind exp_kind + ; return (L span ty') } \end{code} Here comes the main function @@ -576,6 +579,8 @@ gadtSigCtxt ty badGadtDecl ty = hang (ptext SLIT("Malformed constructor signature:")) 2 (ppr ty) + +typeCtxt ty = ptext SLIT("In the type") <+> quotes (ppr ty) \end{code} %************************************************************************