2011-06-16 11:56:34 -07:00
|
|
|
// error-pattern:Number is odd
|
2011-08-23 18:25:50 -07:00
|
|
|
pure fn even(x: uint) -> bool {
|
2011-07-27 14:19:39 +02:00
|
|
|
if x < 2u {
|
|
|
|
ret false;
|
2011-08-19 15:16:48 -07:00
|
|
|
} else if x == 2u { ret true; } else { ret even(x - 2u); }
|
2011-06-16 11:56:34 -07:00
|
|
|
}
|
|
|
|
|
2011-12-22 14:42:52 -08:00
|
|
|
fn foo(x: uint) {
|
|
|
|
if check even(x) {
|
2011-12-22 17:53:53 -08:00
|
|
|
log(debug, x);
|
2011-12-22 14:42:52 -08:00
|
|
|
} else {
|
|
|
|
fail "Number is odd";
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 11:56:34 -07:00
|
|
|
|
2011-08-19 15:16:48 -07:00
|
|
|
fn main() { foo(3u); }
|