Skip to content

Immutable binding becomes mutable in const block expression #15303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kimundi opened this issue Jul 1, 2014 · 2 comments
Closed

Immutable binding becomes mutable in const block expression #15303

Kimundi opened this issue Jul 1, 2014 · 2 comments
Labels
A-type-system Area: Type system

Comments

@Kimundi
Copy link
Member

Kimundi commented Jul 1, 2014

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.
@steveklabnik steveklabnik added the A-type-system Area: Type system label Jan 23, 2015
@steveklabnik
Copy link
Member

Very strange, but still a bug.

@steveklabnik
Copy link
Member

This has gotten fixed somewhere down the line, as both error for me with usize.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 24, 2023
…lowr

Fix highlighting of byte escape sequences

Currently non-UTF8 escape sequences in byte strings and any escape sequences in byte literals are ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants