-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #698 from viperproject/issue-697
Fixes #697
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 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
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,35 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package issue000697 | ||
|
||
// ##(-I ./000697/) | ||
import pkg "pkg" | ||
|
||
type Impl struct{ | ||
x *int | ||
} | ||
|
||
pred (impl Impl) inv() { | ||
acc(impl.x) | ||
} | ||
|
||
func main() { | ||
x@ := 0 | ||
|
||
cl := preserves acc(&x) | ||
func closureImpl() int { | ||
x += 42 | ||
return x | ||
} | ||
|
||
proof cl implements pkg.ClosureSpec{Impl{&x}} { | ||
unfold Impl{&x}.inv() | ||
res = cl() as closureImpl | ||
fold Impl{&x}.inv() | ||
} | ||
|
||
impl := Impl{&x} | ||
fold impl.inv() | ||
pkg.Invoke(cl, impl) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/resources/regressions/issues/000697/pkg/pkg.gobra
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 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package pkg | ||
|
||
type Calls interface { | ||
pred inv() | ||
} | ||
|
||
ghost | ||
requires cs != nil | ||
preserves cs.inv() | ||
func ClosureSpec(ghost cs Calls) (res int) | ||
|
||
requires fn implements ClosureSpec{cs} | ||
requires cs != nil && cs.inv() | ||
ensures cs.inv() | ||
func Invoke(fn func () (int), ghost cs Calls) int { | ||
return fn() as ClosureSpec{cs} | ||
} |