Zero locals when the initializer might call a function

The function might fail, leaving the local uninitialized

Issue #236
This commit is contained in:
Brian Anderson 2011-09-08 13:45:12 -07:00
parent 0ea55ffdc8
commit d267e7486e
2 changed files with 8 additions and 0 deletions

View file

@ -4520,6 +4520,7 @@ fn init_local(bcx: @block_ctxt, local: &@ast::local) -> result {
ast::expr_ret(_) { true }
ast::expr_break. { true }
ast::expr_cont. { true }
ast::expr_call(_, _) { true }
_ {
let ex_ty = ty::expr_ty(e.ccx.tcx, ex);
ty::type_is_bot(e.ccx.tcx, ex_ty)

View file

@ -0,0 +1,7 @@
// error-pattern:fail
fn f() -> @int { fail; }
fn main() {
let a: @int = f();
}