Skip to content
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

Iteration over a range of "negative" length in F* #1346

Open
maximebuyse opened this issue Mar 10, 2025 · 0 comments
Open

Iteration over a range of "negative" length in F* #1346

maximebuyse opened this issue Mar 10, 2025 · 0 comments
Labels
f* F* backend libcore

Comments

@maximebuyse
Copy link
Contributor

maximebuyse commented Mar 10, 2025

fn find (v: &mut Vec<u8>, x: u8) -> bool {
    let mut res = false;
    for i in 1..v.len() {
        if v[i] == x {
            res = true
        }
    }
    res
}

Open this code snippet in the playground

In the example above, F* type-checking fails saying that v[i] cannot be proven to be an access in bounds. If the range of the loop is 0..v.len() it can be proven.

This seems to be a problem with Rust_primitives.Hax.Folds.fold_range when the beginning of the range is possibly strictly inferior to the end of the range.

@maximebuyse maximebuyse added f* F* backend libcore labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f* F* backend libcore
Projects
None yet
Development

No branches or pull requests

1 participant