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

cargo-prusti ignores specification #528

Closed
fpoli opened this issue Jun 1, 2021 · 1 comment · Fixed by #547
Closed

cargo-prusti ignores specification #528

fpoli opened this issue Jun 1, 2021 · 1 comment · Fixed by #547
Assignees
Labels
bug Something isn't working unsoundness Unsoudness in Prusti

Comments

@fpoli
Copy link
Member

fpoli commented Jun 1, 2021

I tried running cargo-prusti on the following crate:

Cargo.toml:

[package]
name = "example"
version = "0.1.0"
edition = "2018"

[dependencies]
prusti-contracts = { git = "https://github.com/viperproject/prusti-dev.git" }

src/main.rs:

use prusti_contracts::*;

#[requires(x > 123)]
fn test(x: i32) {
    assert!(x > 123);
}

fn main() {
    assert!(true);
}

However, the assertion in the test function does not verify and Prusti reports an error. I checked the Viper dump and the x > 123 precondition is not assumed at the beginning of the function, but it should be. I suspect that for some reason all specifications are ignored while running cargo-prusti. Maybe this is related to the cfg(prusti) compilation flag.

This issue also shows that cargo-prusti is not properly tested. We really need #3.

@fpoli fpoli added the bug Something isn't working label Jun 1, 2021
@fpoli fpoli changed the title cargo-prusti ignores specifications cargo-prusti ignores specification Jun 1, 2021
@fpoli
Copy link
Member Author

fpoli commented Jun 8, 2021

This is actually an unsoundness of cargo-prusti, because by ignoring specifications it doesn't generate verification errors for e.g. the following program reported by @rishitc. prusti-rustc and the Prusti IDE don't have this issue.

#![allow(unused)]
fn main() {
    extern crate prusti_contracts;
    use prusti_contracts::*;

    #[ensures((result == a && result != b) || (result == a && result == b))]
    fn max(a: i32, b: i32) -> i32 {
        if a > b {
            a
        } else {
            b
        }
    }
}

@fpoli fpoli added the unsoundness Unsoudness in Prusti label Jun 8, 2021
@fpoli fpoli self-assigned this Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unsoundness Unsoudness in Prusti
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant