diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-22 13:34:43 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-22 13:34:43 +0100 |
| commit | 8015e6d52b7eeea47f9e61c6ac42487935474ca4 (patch) | |
| tree | 1921e75efee6aa0fc4838b01cf01a17698f8b65b | |
| parent | ffd50b9cdfa38bc80f2444d917eef5a02c38c32f (diff) | |
| download | rust-8015e6d52b7eeea47f9e61c6ac42487935474ca4.tar.gz rust-8015e6d52b7eeea47f9e61c6ac42487935474ca4.zip | |
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.
| -rw-r--r-- | src/comp/middle/typeck.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 2ffa191b6d8..ed9eb3c3560 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -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)); } } } |
