Hi!

The following code snippet is well formed and prints 6:

fn main() {
     let x = 5;
     let x = 6;
     println(fmt!("%?",x));
}

I was told this behavior is intentional. However I consider this pattern as
a potential source of errors.
Consider a larger function which one wants to modify. One declares a new
variable in the middle of the function, and if there was a name collosion
the whole meaning of the function is changed and the compiler does not even
provide us with a warning about it.

I'm curious what was the reason of allowing multiple variables with the
same name in the same scope?

Thanks,
Gábor Horváth
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to