Closed
Description
Code (playpen):
static UINT: uint = {
// BUG, allows assigning immutable variable x
fn foo() -> uint {
let x;
x = 100;
x = 200;
x
}
100
};
// OK, produces a error about assigning immutable variable x
fn foo() -> uint {
let x;
x = 100;
x = 200;
x
}
fn main() {
println!("{}", UINT)
}
Complete output:
<anon>:16:5: 16:12 error: re-assignment of immutable variable `x`
<anon>:16 x = 200;
^~~~~~~
<anon>:15:5: 15:12 note: prior assignment occurs here
<anon>:15 x = 100;
^~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101
Program ended.