-
Notifications
You must be signed in to change notification settings - Fork 285
Perform reads checks on ensures of bodiless functions #6264
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
Conversation
…in BoogieGenerator
…as it should also flag the missing reads clause now
|
The failing test Should this check be performed for My first answer would be no, especially given that WDYT? |
|
This reads check, and the accuracy of class {:extern "Int32" } Int32 {
ghost var value: int
}
// Current incorrect spec:
function {:axiom} {:extern} Int32ToInt(value: Int32): int
ensures Int32ToInt(value) == value.value
method UhOh(box: Int32)
requires box.value < 10 // Just to avoid complaints about overflow
modifies box
{
ghost var before := Int32ToInt(box);
assert box.value == before;
box.value := box.value + 1;
ghost var after := Int32ToInt(box);
assert before == after;
assert false;
}Because |
|
Oh nice one! |
|
@robin-aws The test is fixed, and I updated the PR's text to mention it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, love that it pointed out unsoundness in existing specs :)
What was changed?
comp/replaceables/complex/user.dfy: this new feature showed that the specification for these external functions was wrong. For one of the function, a missingreadsclause (flagged by this new feature) allowed to derivefalse. The other function's spec was implying that a function was allocating a new instance (namely ofOption<Int32>whereInt32is an extern class), which is forbidden. So we fix these specs by changing them to be methods instead.How has this been tested?
Add a test to show this new check, update an existing test that includes such a bodiless function with reading ensures and without reads clause.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.