Check all paths return properly in blocks. Closes #874.

This commit is contained in:
Michael Sullivan 2011-08-31 16:15:02 -04:00
parent 722fa00681
commit 7c02517f75
2 changed files with 6 additions and 1 deletions

View file

@ -145,7 +145,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
/* Check that the return value is initialized */
let post = aux::block_poststate(fcx.ccx, f.body);
if f.proto == ast::proto_fn &&
if f.proto != ast::proto_iter &&
!promises(fcx, post, fcx.enclosing.i_return) &&
!type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, id)) &&
f.decl.cf == return {

View file

@ -0,0 +1,5 @@
// error-pattern: not all control paths return
fn force(f: &block() -> int) -> int { f() }
fn main() {
log_err force({| | });
}