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);
}
case (_) {
fcx.ccx.tcx.sess.span_unimpl(expr.span,
"base type for expr_field \
in typeck::check_expr: "
+ ty_to_str(fcx.ccx.tcx,
base_t));
auto t_err = resolve_type_vars_if_possible(fcx, base_t);
auto msg = #fmt("attempted field access on type %s",
ty_to_str(fcx.ccx.tcx, t_err));
fcx.ccx.tcx.sess.span_fatal(expr.span, msg);
}
}
}

View File

@ -1,4 +1,4 @@
// error-pattern: base type for expr_field
// error-pattern: attempted field access
obj x() {
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() {}