diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-09-02 18:43:50 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-09-02 19:05:27 -0700 |
| commit | bdd0417cec937553dec77702bb6b78ed7a07b773 (patch) | |
| tree | 5798c74e461bc5dd88b46b98edd9d6e21bb8e023 /src/comp | |
| parent | b329324f711d364a70a4d0c281e627bf470ef3d6 (diff) | |
| download | rust-bdd0417cec937553dec77702bb6b78ed7a07b773.tar.gz rust-bdd0417cec937553dec77702bb6b78ed7a07b773.zip | |
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!)
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/tstate/states.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index 1b4c14cb95a..a2d33039158 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -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), |
