X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcErrors.lhs;h=c8f624f6ea18d41f2ba54e3ccc3653f5f64be537;hb=038a429f51ad0625ea6bb31a94a40b2aeaeebca6;hp=1254dd6aae252a61eac33231c3ed9f99502b820a;hpb=7e3ec3f3aa3ecaf39cb4519f562ee20debcb5ece;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcErrors.lhs b/compiler/typecheck/TcErrors.lhs index 1254dd6..c8f624f 100644 --- a/compiler/typecheck/TcErrors.lhs +++ b/compiler/typecheck/TcErrors.lhs @@ -396,7 +396,7 @@ typeExtraInfoMsg env ty | Just tv <- tcGetTyVar_maybe ty , isTcTyVar tv , isSkolemTyVar tv || isSigTyVar tv - , not (isUnk tv) + , not (isUnkSkol tv) , let (env1, tv1) = tidySkolemTyVar env tv = (env1, pprSkolTvBinding tv1) where @@ -533,10 +533,11 @@ mkMonomorphismMsg :: ReportErrCtxt -> [TcTyVar] -> TcM (TidyEnv, SDoc) -- ASSUMPTION: the Insts are fully zonked mkMonomorphismMsg ctxt inst_tvs = do { dflags <- getDOpts - ; (tidy_env, docs) <- findGlobals ctxt (mkVarSet inst_tvs) + ; traceTc "Mono" (vcat (map pprSkolTvBinding inst_tvs)) + ; (tidy_env, docs) <- findGlobals ctxt (mkVarSet inst_tvs) ; return (tidy_env, mk_msg dflags docs) } where - mk_msg _ _ | any isRuntimeUnk inst_tvs + mk_msg _ _ | any isRuntimeUnkSkol inst_tvs -- See Note [Runtime skolems] = vcat [ptext (sLit "Cannot resolve unknown runtime types:") <+> (pprWithCommas ppr inst_tvs), ptext (sLit "Use :print or :force to determine these types")] @@ -636,6 +637,22 @@ warnDefaulting wanteds default_ty (loc, ppr_wanteds) = pprWithArising wanteds \end{code} +Note [Runtime skolems] +~~~~~~~~~~~~~~~~~~~~~~ +We want to give a reasonably helpful error message for ambiguity +arising from *runtime* skolems in the debugger. Mostly these +are created by in RtClosureInspec.zonkRTTIType. However at a +breakpoint we return Ids from the CoreExpr, whose types may have +free type variables bound by some enclosing 'forall'. These are +UnkSkols, created ty TcType.zonkQuantifiedTyVar. + +These UnkSkols should never show up as ambiguous type variables in +normal typechecking, so we hackily emit the debugger-related message +both for RuntimeUnkSkols and UnkSkols. Hence the two cases in +TcType.isRuntimeUnkSkol. Yuk. The rest of the debugger is such +a mess that I don't feel motivated to clean up this bit. + + %************************************************************************ %* * Error from the canonicaliser @@ -644,7 +661,7 @@ warnDefaulting wanteds default_ty %************************************************************************ \begin{code} -kindErrorTcS :: CtFlavor -> TcType -> TcType -> TcS () +kindErrorTcS :: CtFlavor -> TcType -> TcType -> TcS a -- If there's a kind error, we don't want to blindly say "kind error" -- We might, say, be unifying a skolem 'a' with a type 'Int', -- in which case that's the error to report. So we set things @@ -654,7 +671,9 @@ kindErrorTcS fl ty1 ty2 do { let ctxt = CEC { cec_encl = [] , cec_extra = extra , cec_tidy = env0 } - ; reportEqErr ctxt ty1 ty2 } + ; reportEqErr ctxt ty1 ty2 + ; failM + } misMatchErrorTcS :: CtFlavor -> TcType -> TcType -> TcS a misMatchErrorTcS fl ty1 ty2 @@ -719,9 +738,9 @@ flattenForAllErrorTcS fl ty _bad_eqs \begin{code} setCtFlavorLoc :: CtFlavor -> TcM a -> TcM a -setCtFlavorLoc (Wanted loc) thing = setCtLoc loc thing -setCtFlavorLoc (Derived loc) thing = setCtLoc loc thing -setCtFlavorLoc (Given loc) thing = setCtLoc loc thing +setCtFlavorLoc (Wanted loc) thing = setCtLoc loc thing +setCtFlavorLoc (Derived loc _) thing = setCtLoc loc thing +setCtFlavorLoc (Given loc) thing = setCtLoc loc thing wrapEqErrTcS :: CtFlavor -> TcType -> TcType -> (TidyEnv -> TcType -> TcType -> SDoc -> TcM a) @@ -740,10 +759,10 @@ wrapEqErrTcS fl ty1 ty2 thing_inside (ctLocOrigin loc) ty1 ty2 ; thing_inside env3 ty1 ty2 extra } ; case fl of - Wanted loc -> do_wanted loc - Derived loc -> do_wanted loc - Given {} -> thing_inside env2 ty1 ty2 empty - -- We could print more info, but it + Wanted loc -> do_wanted loc + Derived loc _ -> do_wanted loc + Given {} -> thing_inside env2 ty1 ty2 empty + -- We could print more info, but it -- seems to be coming out already } } where