eps' <- readIORef eps_var ;
nc' <- readIORef nc_var ;
let { pcs' = PCS { pcs_EPS = eps', pcs_nc = nc' } ;
- final_res | errorsFound msgs = Nothing
- | otherwise = maybe_res } ;
+ final_res | errorsFound dflags msgs = Nothing
+ | otherwise = maybe_res } ;
return (pcs', final_res)
}
where
eps = pcs_EPS pcs
- init_imports = emptyImportAvails { imp_unqual = unitModuleEnv mod emptyAvailEnv }
+ init_imports = emptyImportAvails { imp_qual = unitModuleEnv mod emptyAvailEnv }
-- Initialise tcg_imports with an empty set of bindings for
-- this module, so that if we see 'module M' in the export
-- list, and there are no bindings in M, we don't bleat
new_errs <- readMutVar errs_var ;
+ dflags <- getDOpts ;
+
return (new_errs,
case mb_r of
- Left exn -> Nothing
- Right r | errorsFound new_errs -> Nothing
- | otherwise -> Just r)
+ Left exn -> Nothing
+ Right r | errorsFound dflags new_errs -> Nothing
+ | otherwise -> Just r)
}
tryTcLIE :: TcM a -> TcM (Messages, Maybe a)
ifErrsM bale_out normal
= do { errs_var <- getErrsVar ;
msgs <- readMutVar errs_var ;
- if errorsFound msgs then
+ dflags <- getDOpts ;
+ if errorsFound dflags msgs then
bale_out
else
normal }
getInstLoc :: InstOrigin -> TcM InstLoc
getInstLoc origin
= do { loc <- getSrcLocM ; env <- getLclEnv ;
- return (origin, loc, (tcl_ctxt env)) }
+ return (InstLoc origin loc (tcl_ctxt env)) }
+
+addInstCtxt :: InstLoc -> TcM a -> TcM a
+-- Add the SrcLoc and context from the first Inst in the list
+-- (they all have similar locations)
+addInstCtxt (InstLoc _ src_loc ctxt) thing_inside
+ = addSrcLoc src_loc (updCtxt (\ old_ctxt -> ctxt) thing_inside)
\end{code}
The addErrTc functions add an error message, but do not cause failure.
= do { ctxt <- getErrCtxt ;
loc <- getSrcLocM ;
add_err_tcm tidy_env err_msg loc ctxt }
-
-addInstErrTcM :: InstLoc -> (TidyEnv, Message) -> TcM ()
-addInstErrTcM inst_loc@(_, loc, ctxt) (tidy_env, err_msg)
- = add_err_tcm tidy_env err_msg loc full_ctxt
- where
- full_ctxt = (\env -> returnM (env, pprInstLoc inst_loc)) : ctxt
\end{code}
The failWith functions add an error message and cause failure