forked from dafny-lang/dafny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Count proof obligations of loop headers (dafny-lang#3244)
This PR changes the verifier to increment the assertion count when it encounters a loop with non-free invariants. This increment was previously missing, which caused certain "loop invariant on entry" checks to be omitted (see dafny-lang#3243). Fixes dafny-lang#3243 <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
- Loading branch information
1 parent
6942c7b
commit 6d7bae9
Showing
4 changed files
with
39 additions
and
1 deletion.
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
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,22 @@ | ||
// RUN: %exits-with 4 %dafny /compile:0 "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
method LoopWithBody(x: int) | ||
decreases * | ||
{ | ||
var i := 0; | ||
while i < x | ||
// The following loop-invariant-on-entry check was once omitted when it was the only proof obligation. | ||
invariant i <= x // error: loop invariant does not hold on entry | ||
decreases * | ||
{ | ||
} | ||
} | ||
|
||
method BodylessLoop(x: int) | ||
{ | ||
var i := 0; | ||
while i < x | ||
// The following loop-invariant-on-entry check was once omitted when it was the only proof obligation. | ||
invariant i <= x // error: loop invariant does not hold on entry | ||
} |
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,7 @@ | ||
git-issue-3243.dfy(19,2): Warning: note, this loop has no body (loop frame: i) | ||
git-issue-3243.dfy(10,16): Error: This loop invariant might not hold on entry. | ||
git-issue-3243.dfy(10,16): Related message: loop invariant violation | ||
git-issue-3243.dfy(21,16): Error: This loop invariant might not hold on entry. | ||
git-issue-3243.dfy(21,16): Related message: loop invariant violation | ||
|
||
Dafny program verifier finished with 0 verified, 2 errors |
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 @@ | ||
Check loop invariants on entry, even when such are the only proof obligations in a method. |