rustc: Convert field access on invalid types from an ICE to a fatal error
Closes #367
This commit is contained in:
parent
d9f452a2a8
commit
54566e9037
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: base type for expr_field
|
||||
// error-pattern: attempted field access
|
||||
|
||||
obj x() {
|
||||
fn hello() {
|
||||
|
10
src/test/compile-fail/vec-field.rs
Normal file
10
src/test/compile-fail/vec-field.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user