-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
945: some fixes and regression tests for #738 related to retaining domain axioms r=vakaras a=Pointerbender I found a few more cases where the definition collector is a little too strict when removing domain axioms (#738). I included some fixes and regression tests in this PR. A short summary of the changes: I extended the logic that determines whether to retain the domain axioms to also include cases such as: * Retain the injectivity axiom when the constructor is "used". * Also retain the field axiom when the field access snap function is used. On top of that, I had to change a bit of logic in `prusti-viper/src/encoder/mir/pure/pure_functions/encoder.rs` so that Prusti encoded the type bound preconditions before the other preconditions. Apparently the order in which these are defined matters for Viper (tested by regression test `issue-738-4.rs`). (This PR does not fully fix the related issue #738) Co-authored-by: Pointerbender <pointerbender@gmail.com>
- Loading branch information
Showing
7 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
prusti-tests/tests/verify_overflow/pass/issues/issue-738-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use prusti_contracts::*; | ||
|
||
fn main() {} | ||
|
||
#[pure] | ||
pub fn get(a: &usize) -> usize { | ||
*a | ||
} | ||
fn foo(a: &usize) { | ||
let v = get(a); | ||
} |
16 changes: 16 additions & 0 deletions
16
prusti-tests/tests/verify_overflow/pass/issues/issue-738-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use prusti_contracts::*; | ||
|
||
#[requires(test(1).a == 1)] | ||
fn main() {} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct A { | ||
a: usize | ||
} | ||
|
||
#[pure] | ||
#[requires(a <= isize::MAX as usize)] | ||
#[ensures(result.a <= isize::MAX as usize)] | ||
pub fn test(a: usize) -> A { | ||
A { a: a as isize as usize as isize as usize } | ||
} |
28 changes: 28 additions & 0 deletions
28
prusti-tests/tests/verify_overflow/pass/issues/issue-738-4.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use prusti_contracts::*; | ||
|
||
fn main() { | ||
bar(1, 1); | ||
bar(1, 2); | ||
baz(1, 1); | ||
baz(1, 2); | ||
} | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq)] | ||
pub struct A { | ||
a: usize | ||
} | ||
|
||
#[pure] | ||
pub fn foo(a: usize) -> A { | ||
A { a } | ||
} | ||
|
||
/// Test surjectivity | ||
#[pure] | ||
#[requires(a == b ==> foo(a) == foo(b))] | ||
pub fn bar(a: usize, b: usize) {} | ||
|
||
/// Test injectivity | ||
#[pure] | ||
#[requires(foo(a) == foo(b) ==> a == b)] | ||
pub fn baz(a: usize, b: usize) {} |
11 changes: 11 additions & 0 deletions
11
prusti-tests/tests/verify_overflow/pass/issues/issue-738-5.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use prusti_contracts::*; | ||
|
||
fn main() {} | ||
|
||
#[pure] | ||
pub fn get(a: &&&usize) -> usize { | ||
***a | ||
} | ||
fn foo(a: &&&usize) { | ||
let v = get(a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters