Open sarsko opened 1 year ago
I can't reproduce this? the test case above works on the latest master for me.
Hmm, I updated to most recent master and it is failing for me.
I have a src/lib.rs
as so:
#![feature(type_ascription)]
#![cfg_attr(not(creusot), feature(stmt_expr_attributes, proc_macro_hygiene))]
#![allow(unused_imports)]
#![allow(unused)]
#![allow(dead_code)]
#![allow(non_snake_case)]
mod test;
and a src/test.rs
like so:
extern crate creusot_contracts;
use creusot_contracts::*;
struct Heap {
activity: Vec<f64>,
heap: Vec<usize>,
indices: Vec<usize>,
num_vars: usize,
}
impl Heap {
pub(crate) fn new(n: usize) -> Self {
let mut heap = Heap { activity: Vec::new(), heap: Vec::new(), indices: Vec::new(), num_vars: 0 };
let mut i = 0;
#[invariant(heap.heap@.len() == i@)]
while i < n {
i += 1;
}
heap
}
}
and a Cargo.toml
like so:
[package]
name = "Scratch"
version = "0.1.0"
edition = "2021"
[dependencies]
creusot-contracts = { git = "https://github.com/xldenis/creusot", version = "^0", rev = "e1a80db" }
And then it panics on unwrap when doing:
cargo creusot -- -p Scratch
Could probably be reduced further, but, this code:
causes the following error. Happens both on current master as well as the one I was on before (5cc6cdd6). Could probably be reduced further. Goes away when the invariant is removed or swapped with something else.