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

Incorrect usage of old when it is not #1530

Closed
mario-bucev opened this issue May 17, 2024 · 0 comments · Fixed by #1532
Closed

Incorrect usage of old when it is not #1530

mario-bucev opened this issue May 17, 2024 · 0 comments · Fixed by #1532
Assignees

Comments

@mario-bucev
Copy link
Collaborator

In the following snippet, Stainless complains that the old in inner1 may only occur in postcondition, even though that's the case:

import stainless.lang.*

object OldInInnerFn {
  case class A(var i: BigInt)

  def outer1(a: A): Unit = {
    def inner1(a: A): Unit = {
      ()
    }.ensuring(_ => a.i == old(a).i) // "Stainless `old` can only occur in postconditions"
  }

  // This is ok
  def outer2(a: A): Unit = {
    def inner2(): Unit = {
    }.ensuring(_ => a.i == old(a).i)
  }
}

It seems to happen in the particular case where the variables are untouched.

@mario-bucev mario-bucev self-assigned this May 17, 2024
mario-bucev added a commit to mario-bucev/stainless that referenced this issue May 17, 2024
@mario-bucev mario-bucev mentioned this issue May 17, 2024
vkuncak added a commit that referenced this issue May 19, 2024
…en if variable is unchanged

Co-authored-by: Viktor Kunčak <vkuncak@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

1 participant