7fc89f573d
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.
26 lines
273 B
Rust
26 lines
273 B
Rust
// xfail-stage0
|
|
pred even(uint x) -> bool {
|
|
if (x < 2u) {
|
|
ret false;
|
|
}
|
|
else if (x == 2u) {
|
|
ret true;
|
|
}
|
|
else {
|
|
ret even(x - 2u);
|
|
}
|
|
}
|
|
|
|
fn foo(uint x) -> () {
|
|
if check(even(x)) {
|
|
log x;
|
|
}
|
|
else {
|
|
fail;
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
foo(2u);
|
|
}
|