rust/src/test/compile-fail/if-check-precond-fail.rs

12 lines
324 B
Rust
Raw Normal View History

// error-pattern:Unsatisfied precondition constraint
2011-07-27 14:19:39 +02:00
pred even(x: uint) -> bool {
if x < 2u {
ret false;
} else if (x == 2u) { ret true; } else { ret even(x - 2u); }
}
2011-07-27 14:48:34 +02:00
fn print_even(x: uint) : even(x) { log x; }
2011-07-27 14:19:39 +02:00
fn foo(x: uint) { if check even(x) { fail; } else { print_even(x); } }
2011-07-27 14:19:39 +02:00
fn main() { foo(3u); }