Skip to content

Commit ea47f06

Browse files
committed
---
yaml --- r: 2837 b: refs/heads/master c: 18883fe h: refs/heads/master i: 2835: c067d50 v: v3
1 parent b401e91 commit ea47f06

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 95e1aa18c1290d087516bd417590a181300cfc6b
2+
refs/heads/master: 18883fea3a5c3c1a9af5c8a29464b83c0c81757b

trunk/src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import aux::ann_to_def;
3939
import aux::ann_to_def_strict;
4040
import aux::ann_to_ts_ann;
4141
import aux::set_postcond_false;
42+
import aux::controlflow_expr;
4243

4344
import bitvectors::seq_preconds;
4445
import bitvectors::union_postconds;
@@ -78,6 +79,7 @@ import front::ast::def;
7879
import front::ast::lit;
7980
import front::ast::init_op;
8081
import front::ast::controlflow;
82+
import front::ast::noreturn;
8183
import front::ast::return;
8284
import front::ast::_fn;
8385
import front::ast::_obj;
@@ -294,6 +296,13 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) -> () {
294296
auto args = vec::clone[@expr](operands);
295297
vec::push[@expr](args, operator);
296298
find_pre_post_exprs(fcx, args, a);
299+
/* if this is a failing call, its postcondition sets everything */
300+
alt (controlflow_expr(fcx.ccx, operator)) {
301+
case (noreturn) {
302+
set_postcond_false(fcx.ccx, a);
303+
}
304+
case (_) { }
305+
}
297306
}
298307
case (expr_spawn(_, _, ?operator, ?operands, ?a)) {
299308
auto args = vec::clone[@expr](operands);
@@ -495,8 +504,8 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) -> () {
495504
case (expr_index(?e, ?sub, ?a)) {
496505
find_pre_post_exprs(fcx, [e, sub], a);
497506
}
498-
case (expr_alt(?e, ?alts, ?a)) {
499-
find_pre_post_expr(fcx, e);
507+
case (expr_alt(?ex, ?alts, ?a)) {
508+
find_pre_post_expr(fcx, ex);
500509
fn do_an_alt(&fn_ctxt fcx, &arm an_alt) -> pre_and_post {
501510
find_pre_post_block(fcx, an_alt.block);
502511
ret block_pp(fcx.ccx, an_alt.block);
@@ -510,7 +519,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) -> () {
510519
intersect(pp.postcondition, next.postcondition);
511520
ret pp;
512521
}
513-
auto antec_pp = pp_clone(expr_pp(fcx.ccx, e));
522+
auto antec_pp = pp_clone(expr_pp(fcx.ccx, ex));
514523
auto e_pp = @rec(precondition=empty_prestate(num_local_vars),
515524
postcondition=false_postcond(num_local_vars));
516525
auto g = bind combine_pp(antec_pp, fcx, _, _);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std;
2+
import std::option::*;
3+
4+
fn baz() -> ! {
5+
fail;
6+
}
7+
8+
fn foo() {
9+
alt (some[int](5)) {
10+
case (some[int](?x)) {
11+
auto bar;
12+
alt (none[int]) {
13+
case (none[int]) {
14+
bar = 5;
15+
}
16+
case (_) {
17+
baz();
18+
}
19+
}
20+
log bar;
21+
}
22+
case (none[int]) {
23+
log "hello";
24+
}
25+
}
26+
}
27+
28+
fn main() {
29+
foo();
30+
}

0 commit comments

Comments
 (0)