-
Notifications
You must be signed in to change notification settings - Fork 22
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
Failing to assume invariants on field when unfolding a struct #451
Comments
Good catch! @nilehmann I thought it was due to the two occurrences of #![feature(register_tool)]
#![register_tool(flux)]
struct A {
val: u32,
}
#[flux::sig(fn (bool[true]))]
fn assert(_b:bool) {}
impl A {
fn f(&mut self) {
let tmp = self.val;
assert(tmp >= 0); // THIS ASSERTION ALSO FAILS
if tmp == 0 {
return;
}
let a = tmp - 1;
}
} |
Furthermore, adding this makes stuff work (if you have a single struct A {
#[flux::field(u32{v:0 <= v})]
val: u32,
} |
Coming a bit late to the game but this definitively looks like a bug. The issue seems to be that we are not correctly assuming the invariants on We try to be smart about when to assume invariants on types to avoid unnecessarily polluting the constraint with extra facts, but in doing so we are failing to do it in some places. |
#541 solves the problem of not correctly assuming the type invariants when creating the temporary. To solve the original problem we need to implement unfolding of mutable references. |
Why is the following program considered not safe ?
but the following is considered safe ?
The text was updated successfully, but these errors were encountered: