Restructure the "checking" pass in typestate

I noticed that typestate was being lazier than it should be,
because it was only checking typestate for statements and
top-level expression (that is, the expression in a stmt_expr, but
not any subexpressions). So I rewrote the checks in tstate/ck.rs
to use walk, which exposed a few bugs in typestate that I fixed.

Also added some more test cases for if-check.
This commit is contained in:
Tim Chevalier 2011-06-17 19:07:23 -07:00
parent a4eb6630f3
commit 7fc89f573d
9 changed files with 386 additions and 123 deletions

View file

@ -0,0 +1,30 @@
// xfail-stage0
// error-pattern:Unsatisfied precondition constraint
pred even(uint x) -> bool {
if (x < 2u) {
ret false;
}
else if (x == 2u) {
ret true;
}
else {
ret even(x - 2u);
}
}
fn print_even(uint x) : even(x) {
log x;
}
fn foo(uint x) -> () {
if check(even(x)) {
fail;
}
else {
print_even(x);
}
}
fn main() {
foo(3u);
}