Handle if-check with no else correctly in typestate

Propagate the if-check constraint into the consequent even when
there's no else branch. (Oops!)
This commit is contained in:
Tim Chevalier 2011-09-02 18:43:50 -07:00
parent b329324f71
commit bdd0417cec

View file

@ -264,12 +264,25 @@ fn join_then_else(fcx: &fn_ctxt, antec: &@expr, conseq: &blk,
alt maybe_alt {
none. {
changed |=
find_pre_post_state_block(fcx, expr_poststate(fcx.ccx, antec),
conseq) |
alt chk {
if_check. {
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
let conseq_prestate = tritv_clone(expr_poststate(fcx.ccx, antec));
tritv_set(bit_num(fcx, c.node), conseq_prestate, ttrue);
changed |=
find_pre_post_state_block(fcx, conseq_prestate, conseq) |
set_poststate_ann(fcx.ccx, id,
expr_poststate(fcx.ccx, antec));
}
}
_ {
changed |=
find_pre_post_state_block(fcx, expr_poststate(fcx.ccx, antec),
conseq) |
set_poststate_ann(fcx.ccx, id,
expr_poststate(fcx.ccx, antec));
}
}
}
some(altern) {
changed |=
find_pre_post_state_expr(fcx, expr_poststate(fcx.ccx, antec),