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

Closure implementation proof of imported spec crashes Gobra #697

Closed
ArquintL opened this issue Oct 27, 2023 · 0 comments · Fixed by #698
Closed

Closure implementation proof of imported spec crashes Gobra #697

ArquintL opened this issue Oct 27, 2023 · 0 comments · Fixed by #698
Assignees
Labels
bug Something isn't working desugaring

Comments

@ArquintL
Copy link
Member

The following code results in a violation within the desugarer:
main.gobra:

package main

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()
    }
}

pkg/pkg.gobra:

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}
}
@ArquintL ArquintL added bug Something isn't working desugaring labels Oct 27, 2023
@ArquintL ArquintL self-assigned this Oct 27, 2023
@ArquintL ArquintL mentioned this issue Oct 27, 2023
ArquintL added a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working desugaring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant