= do { loc <- getSrcSpanM ; env <- getLclEnv ;
return (InstLoc origin loc (tcl_ctxt env)) }
-addInstCtxt :: InstLoc -> TcM a -> TcM a
+setInstCtxt :: InstLoc -> TcM a -> TcM a
-- Add the SrcSpan and context from the first Inst in the list
-- (they all have similar locations)
-addInstCtxt (InstLoc _ src_loc ctxt) thing_inside
- = setSrcSpan src_loc (updCtxt (\_ -> ctxt) thing_inside)
+setInstCtxt (InstLoc _ src_loc ctxt) thing_inside
+ = setSrcSpan src_loc (setErrCtxt ctxt thing_inside)
\end{code}
The addErrTc functions add an error message, but do not cause failure.
(friends, others) = partition is_friend insts
loc_msg = showSDoc (pprInstLoc (instLoc inst))
is_friend friend = showSDoc (pprInstLoc (instLoc friend)) == loc_msg
- do_one insts = addInstCtxt (instLoc (head insts)) (report_err insts)
+ do_one insts = setInstCtxt (instLoc (head insts)) (report_err insts)
-- Add location and context information derived from the Insts
-- Add the "arising from..." part to a message about bunch of dicts
warnDefault :: [(Inst, Class, Var)] -> Type -> TcM ()
warnDefault ups default_ty = do
warn_flag <- doptM Opt_WarnTypeDefaults
- addInstCtxt (instLoc (head (dicts))) (warnTc warn_flag warn_msg)
+ setInstCtxt (instLoc (head (dicts))) (warnTc warn_flag warn_msg)
where
dicts = [d | (d,_,_) <- ups]
eqInstMisMatch :: Inst -> TcM a
eqInstMisMatch inst
= ASSERT( isEqInst inst )
- setErrCtxt ctxt $ failWithMisMatch ty_act ty_exp
+ setInstCtxt (instLoc inst) $ failWithMisMatch ty_act ty_exp
where
(ty_act, ty_exp) = eqInstTys inst
- InstLoc _ _ ctxt = instLoc inst
-----------------------
failWithMisMatch :: TcType -> TcType -> TcM a