-
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.
Fix lowering for quantifiers that use closures over function arguments
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
prusti-tests/tests/verify/fail/native/quantifier_closures.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,20 @@ | ||
// compile-flags: -Pviper_backend=Lithium | ||
use prusti_contracts::*; | ||
|
||
#[requires(forall(|x: i32| x * x >= foo * bar))] //~ ERROR precondition might not hold | ||
fn test_closure_1(foo: i32, bar: i32) -> i32 { | ||
foo + bar + 1 | ||
} | ||
|
||
#[requires(forall(|x: i32| x * x >= foo * bar))] //TODO: both errors reported | ||
fn test_closure_2(foo: i32, bar: i32) -> i32 { | ||
foo + bar + 1 | ||
} | ||
|
||
fn main() { | ||
test_closure_1(5, 3); //TODO: error reported here | ||
|
||
let arg1 = 1; | ||
let arg2 = 2; | ||
test_closure_2(arg1, arg2); //TODO: error reported here | ||
} |
15 changes: 15 additions & 0 deletions
15
prusti-tests/tests/verify/pass/native/quantifier_closures.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,15 @@ | ||
// compile-flags: -Pviper_backend=Lithium | ||
use prusti_contracts::*; | ||
|
||
#[requires(forall(|x: i32| x * x >= foo * bar))] | ||
fn test_closure(foo: i32, bar: i32) -> i32 { | ||
foo + bar + 1 | ||
} | ||
|
||
fn main() { | ||
test_closure(0, 0); | ||
|
||
let arg1 = 0; | ||
let arg2 = 0; | ||
test_closure(arg1, arg2); | ||
} |
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