Make typestate properly descend pattern guards

Closes #1265
This commit is contained in:
Marijn Haverbeke 2011-12-07 14:09:45 +01:00
parent 9656ceac60
commit d28e0c0c0a
2 changed files with 10 additions and 0 deletions

View File

@ -452,6 +452,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
expr_alt(ex, alts) {
find_pre_post_expr(fcx, ex);
fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post {
alt an_alt.guard {
some(e) { find_pre_post_expr(fcx, e); }
_ {}
}
find_pre_post_block(fcx, an_alt.body);
ret block_pp(fcx.ccx, an_alt.body);
}

View File

@ -530,6 +530,12 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
if vec::len(alts) > 0u {
a_post = false_postcond(num_constrs);
for an_alt: arm in alts {
alt an_alt.guard {
some(e) {
changed |= find_pre_post_state_expr(fcx, e_post, e);
}
_ {}
}
changed |=
find_pre_post_state_block(fcx, e_post, an_alt.body);
intersect(a_post, block_poststate(fcx.ccx, an_alt.body));