Skip to content

loop can mask state changes in typestate #2374

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
paulstansifer opened this issue May 10, 2012 · 0 comments
Closed

loop can mask state changes in typestate #2374

paulstansifer opened this issue May 10, 2012 · 0 comments
Milestone

Comments

@paulstansifer
Copy link
Contributor

The following (compile-fail/loop-pred-constraints.rs) should not compile:

fn print_even(y: int) : even(y) { log(debug, y); }
pure fn even(y: int) -> bool { true }

fn main() {
    let mut y = 42;
    check (even(y));
    loop {
        print_even(y);
        loop { y += 1; break; }
    }
}

Removing the inner loop or changing it to a do (back when `do existed) gives the correct error.

@ghost ghost assigned catamorphism May 11, 2012
tshepang added a commit to tshepang/rust that referenced this issue May 8, 2025
tshepang added a commit to tshepang/rust that referenced this issue May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants