Skip to content

Commit 7c02517

Browse files
committed
Check all paths return properly in blocks. Closes #874.
1 parent 722fa00 commit 7c02517

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/comp/middle/tstate/ck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
145145

146146
/* Check that the return value is initialized */
147147
let post = aux::block_poststate(fcx.ccx, f.body);
148-
if f.proto == ast::proto_fn &&
148+
if f.proto != ast::proto_iter &&
149149
!promises(fcx, post, fcx.enclosing.i_return) &&
150150
!type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, id)) &&
151151
f.decl.cf == return {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern: not all control paths return
2+
fn force(f: &block() -> int) -> int { f() }
3+
fn main() {
4+
log_err force({| | });
5+
}

0 commit comments

Comments
 (0)