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

Support struct field accessing in loop contracts #3700

Open
qinheping opened this issue Nov 8, 2024 · 0 comments
Open

Support struct field accessing in loop contracts #3700

qinheping opened this issue Nov 8, 2024 · 0 comments
Assignees
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@qinheping
Copy link
Contributor

Requested feature: Support of using struct.field in loop contracts
Use case: #[kani::loop_invariant(h.x == 2)]
Link to relevant documentation (Rust reference, Nomicon, RFC): #3167

Test case:

struct hole{
    x: u8
}

#[kani::proof]
fn simple_while_loop_harness() {
    let mut h: hole = hole{ x: kani::any_where(|i| *i >= 2)};
    #[kani::loop_invariant(h.x == 2)]
    while h.x > 2 {
        h.x = h.x - 1;
    }

    assert!(h.x == 2);
}
@qinheping qinheping added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Nov 8, 2024
@qinheping qinheping self-assigned this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant