Return a new type var instead of nil when failing to typecheck a field

The previous solution was usually causing a second spurious error
message.
This commit is contained in:
Marijn Haverbeke 2012-02-22 13:34:43 +01:00
parent ffd50b9cdf
commit 8015e6d52b

View File

@ -1146,8 +1146,10 @@ mod writeback {
typ) {
fix_ok(new_type) { ret some(new_type); }
fix_err(vid) {
fcx.ccx.tcx.sess.span_err(sp, "cannot determine a type \
for this expression");
if !fcx.ccx.tcx.sess.has_errors() {
fcx.ccx.tcx.sess.span_err(sp, "cannot determine a type \
for this expression");
}
ret none;
}
}
@ -2546,7 +2548,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
field, ty_to_str(tcx, t_err)];
tcx.sess.span_err(expr.span, msg);
// NB: Adding a bogus type to allow typechecking to continue
write_ty(tcx, id, ty::mk_nil(tcx));
write_ty(tcx, id, next_ty_var(fcx));
}
}
}