Check all paths return properly in blocks. Closes #874.
This commit is contained in:
parent
722fa00681
commit
7c02517f75
2 changed files with 6 additions and 1 deletions
|
@ -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 {
|
||||
|
|
5
src/test/compile-fail/block-require-return.rs
Normal file
5
src/test/compile-fail/block-require-return.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
// error-pattern: not all control paths return
|
||||
fn force(f: &block() -> int) -> int { f() }
|
||||
fn main() {
|
||||
log_err force({| | });
|
||||
}
|
Loading…
Add table
Reference in a new issue