Closed
Description
So, I just wasted an hour pulling my hair out about this. Minimal program:
fn main(){
let result = Some(~"Something went wrong!");
match copy result {
Some(error) => io::println(error),
None => ()
}
}
rustc version: 09bb07b (master from a few weeks ago)
rustc output:
fuuu.rs:4:35: 4:40 error: mismatched types: expected `&/str` but found `u32` (expected &/str but found u32)
fuuu.rs:4 Some(error) => io::println(error),
^~~~~
error: aborting due to previous error
This error message is terrible. What’s going on here is that error
is a constant from libcore.
The message when using the name of a constant for a new variable is not much better:
fuuu.rs:2:8: 2:15 error: only refutable patterns allowed here
fuuu.rs:2 let error = 4;
^~~~~~~
error: aborting due to previous error
Shouldn’t scoping take care of this? Variables should be able to "mask" constants as long as they’re in scope.