rust/src/test/compile-fail/if-check-precond-fail.rs
2012-03-05 17:05:20 -08:00

13 lines
334 B
Rust

// error-pattern:unsatisfied precondition constraint
pure fn even(x: uint) -> bool {
if x < 2u {
ret false;
} else if x == 2u { ret true; } else { ret even(x - 2u); }
}
fn print_even(x: uint) : even(x) { log(debug, x); }
fn foo(x: uint) { if check even(x) { fail; } else { print_even(x); } }
fn main() { foo(3u); }