Skip to content

Commit d267e74

Browse files
committed
Zero locals when the initializer might call a function
The function might fail, leaving the local uninitialized Issue #236
1 parent 0ea55ff commit d267e74

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/comp/middle/trans.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4520,6 +4520,7 @@ fn init_local(bcx: @block_ctxt, local: &@ast::local) -> result {
45204520
ast::expr_ret(_) { true }
45214521
ast::expr_break. { true }
45224522
ast::expr_cont. { true }
4523+
ast::expr_call(_, _) { true }
45234524
_ {
45244525
let ex_ty = ty::expr_ty(e.ccx.tcx, ex);
45254526
ty::type_is_bot(e.ccx.tcx, ex_ty)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// error-pattern:fail
2+
3+
fn f() -> @int { fail; }
4+
5+
fn main() {
6+
let a: @int = f();
7+
}

0 commit comments

Comments
 (0)