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

13 lines
334 B
Rust
Raw Normal View History

2012-03-05 16:27:27 -08:00
// error-pattern:unsatisfied precondition constraint
pure fn even(x: uint) -> bool {
2011-07-27 14:19:39 +02:00
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); }
2011-07-27 14:19:39 +02:00
fn foo(x: uint) { if check even(x) { fail; } else { print_even(x); } }
fn main() { foo(3u); }