-
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.
Raise an error if old() expressions are used in local vars outside of…
… loops (#1482) Raise an error if local vars occur within an old() expression
- Loading branch information
Showing
4 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
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,10 @@ | ||
extern crate prusti_contracts; | ||
use prusti_contracts::*; | ||
|
||
fn blah(y: i32){ | ||
let x = 1; | ||
prusti_assert!(old(x) == 1); //~ ERROR old expressions should not contain local variables | ||
} | ||
|
||
fn main(){ | ||
} |
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 @@ | ||
use prusti_contracts::*; | ||
|
||
pub struct Wrapper(u32); | ||
|
||
impl Wrapper { | ||
#[pure] | ||
pub fn get(&self) -> u32 { | ||
self.0 | ||
} | ||
|
||
} | ||
|
||
fn capitalize(vec: &mut Wrapper) { | ||
while true { | ||
body_invariant!(vec.get() == old(vec.get())); | ||
} | ||
} | ||
|
||
fn main(){ | ||
} |
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