1
Fork 0

rustc: Convert field access on invalid types from an ICE to a fatal error

Closes #367
This commit is contained in:
Brian Anderson 2011-06-22 21:22:27 -07:00
parent d9f452a2a8
commit 54566e9037
3 changed files with 15 additions and 6 deletions

View file

@ -1994,11 +1994,10 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
write::ty_only_fixup(fcx, id, t); write::ty_only_fixup(fcx, id, t);
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_unimpl(expr.span, auto t_err = resolve_type_vars_if_possible(fcx, base_t);
"base type for expr_field \ auto msg = #fmt("attempted field access on type %s",
in typeck::check_expr: " ty_to_str(fcx.ccx.tcx, t_err));
+ ty_to_str(fcx.ccx.tcx, fcx.ccx.tcx.sess.span_fatal(expr.span, msg);
base_t));
} }
} }
} }

View file

@ -1,4 +1,4 @@
// error-pattern: base type for expr_field // error-pattern: attempted field access
obj x() { obj x() {
fn hello() { fn hello() {

View file

@ -0,0 +1,10 @@
// xfail-stage0
// error-pattern:attempted field access on type vec\[int\]
// issue #367
fn f() {
auto v = [1];
log v.some_field_name; //type error
}
fn main() {}