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

introduce old outside of post condition #1551

Open
samuelchassot opened this issue Aug 5, 2024 · 1 comment
Open

introduce old outside of post condition #1551

samuelchassot opened this issue Aug 5, 2024 · 1 comment
Assignees

Comments

@samuelchassot
Copy link
Collaborator

It can be implemented a sugar instead of writing a snapshot at the beginning of the body:

def f() = 
  // mutable operations
  assert(old(this).size > this.size)
  // ...

would be transformed into

def f() = 
  @ghost val oldthis = snapshot(this)
  // mutable operations
  assert(oldThis.size > this.size)
  // ...
@vkuncak
Copy link
Collaborator

vkuncak commented Aug 11, 2024

Be careful about semantics when using old in nested functions, as this could lead to some ambuguity if there is variable shadowing: did the user mean old as "at the entry of the inner function", as in "at the entry of outer function". The behavior of whether the variable is considered changed by a nested function has changed recently in #1532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants