Skip to content

Commit d28e0c0

Browse files
committed
Make typestate properly descend pattern guards
Closes #1265
1 parent 9656cea commit d28e0c0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
452452
expr_alt(ex, alts) {
453453
find_pre_post_expr(fcx, ex);
454454
fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post {
455+
alt an_alt.guard {
456+
some(e) { find_pre_post_expr(fcx, e); }
457+
_ {}
458+
}
455459
find_pre_post_block(fcx, an_alt.body);
456460
ret block_pp(fcx.ccx, an_alt.body);
457461
}

src/comp/middle/tstate/states.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
530530
if vec::len(alts) > 0u {
531531
a_post = false_postcond(num_constrs);
532532
for an_alt: arm in alts {
533+
alt an_alt.guard {
534+
some(e) {
535+
changed |= find_pre_post_state_expr(fcx, e_post, e);
536+
}
537+
_ {}
538+
}
533539
changed |=
534540
find_pre_post_state_block(fcx, e_post, an_alt.body);
535541
intersect(a_post, block_poststate(fcx.ccx, an_alt.body));

0 commit comments

Comments
 (0)