- (tcg_env, rn_decls) <- rnTopSrcDecls first_group ;
- ((tcg_env, tcl_env), lie) <- getLIE $ setGblEnv tcg_env $
- tcTopSrcDecls boot_details rn_decls ;
-
- -- tcSimplifyTop deals with constant or ambiguous InstIds.
- -- How could there be ambiguous ones? They can only arise if a
- -- top-level decl falls under the monomorphism restriction
- -- and no subsequent decl instantiates its type.
- traceTc (text "Tc8") ;
- inst_binds <- setEnvs (tcg_env, tcl_env) (tcSimplifyTop lie) ;
- -- Setting the global env exposes the instances to tcSimplifyTop
- -- Setting the local env exposes the local Ids to tcSimplifyTop,
- -- so that we get better error messages (monomorphism restriction)
-
- let { tcg_env' = tcg_env { tcg_binds = tcg_binds tcg_env `unionBags` inst_binds } } ;
-
- setEnvs (tcg_env', tcl_env) $
+ (tcg_env, rn_decls) <- checkNoErrs $ rnTopSrcDecls first_group ;
+ -- checkNoErrs: don't typecheck if renaming failed
+ tc_envs <- setGblEnv tcg_env $
+ tcTopSrcDecls boot_details rn_decls ;