Skip to content

Commit

Permalink
Merge pull request #698 from viperproject/issue-697
Browse files Browse the repository at this point in the history
Fixes #697
  • Loading branch information
ArquintL authored Feb 6, 2024
2 parents 1360097 + b487054 commit a2915f9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
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}
}

0 comments on commit a2915f9

Please sign in to comment.