rust/src/test/compile-fail/forgot-ret.rs
Marijn Haverbeke be5537e95f Be more strict about what constitutes a block expression
Blocks (or statements involving blocks) that end in a semicolon are no
longer considered the block-expression of their outer block. This used
to be an expression block, but now is a statement block:

    { if foo { ret 1; } else { ret 10; } }

This helps clear up some ambiguities in our grammar.
2011-09-13 15:50:03 +02:00

9 lines
199 B
Rust

// -*- rust -*-
// error-pattern: not all control paths return a value
fn god_exists(a: int) -> bool { be god_exists(a); }
fn f(a: int) -> int { if god_exists(a) { ret 5; } }
fn main() { f(12); }