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

Unexpected behaviour difference function application vs. asserting precondition #393

Open
mschwerhoff opened this issue Jul 21, 2021 · 0 comments

Comments

@mschwerhoff
Copy link
Contributor

The example below illustrates a difference in behaviour between invoking a function — which entails asserting its precondition — and explicitly asserting the function's precondition: in the former case, the precondition is not assumed to hold afterwards.

field f: Int

function foo(x: Ref): Bool 
  requires acc(x.f)

method test(x: Ref) {
  inhale acc(x.f) && x.f == 1
  var y: Ref
  
  assert foo(y)    // Error: insuff. permissions
  assert acc(y.f)  // Error: insuff. permissions
  
  assert y.f == 1 // No error, thanks to assert
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant