Closed
Description
This is part of the Rust tutorial session. The whole purpose of the exercise was to find a mistake in the block expression.
See Exercise 2.1
http://pnkfelix.github.io/cyot/tutorial/exercises/ex_part_2
With rust compile this:
fn foo() -> i32 {
42
}
pub fn main() {
let the_sum :i32 = {
foo();
};
let the_other_sum = {
foo();
};
}
It outputs this error:
bug_block.rs:7:24: 9:6 error: mismatched types:
expected `i32`,
found `()`
(expected i32,
found ()) [E0308]
bug_block.rs:7 let the_sum :i32 = {
bug_block.rs:8 foo();
bug_block.rs:9 };
error: aborting due to previous error
It should also put a warning for line 12: "possibly missing return value". This would catch the bug.