Skip to content
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

Fixes #697 #698

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/scala/viper/gobra/frontend/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4532,10 +4532,10 @@ object Desugar extends LazyLogging {

case n: PInvoke =>
// a predicate invocation corresponds to a predicate access with full permissions
// register the full permission AST node in the position manager such that its meta information
// register the full permission AST node in `info`'s position manager such that its meta information
// is retrievable in predicateCallD
val perm = PFullPerm()
pom.positions.dupPos(n, perm)
info.tree.root.positions.positions.dupPos(n, perm)
predicateCallD(ctx, info)(n, perm)

case PForall(vars, triggers, body) =>
Expand Down
35 changes: 35 additions & 0 deletions src/test/resources/regressions/issues/000697.gobra
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 src/test/resources/regressions/issues/000697/pkg/pkg.gobra
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}
}
Loading