Skip to content

Opaque blocks prove variable previously assigned #6363

@MikaelMayer

Description

@MikaelMayer

Dafny version

latest-nightly

Code to produce this issue

method FreshEnsures() {
  var c: int;
  ghost var wasAssigned := assigned(c);
  opaque ensures c == 1 {
    c := 1;
  }
  assert wasAssigned;
}

Command to run and resulting output

dafny verify

What happened?

In a time-traveling verification superpower, Dafny is able to prove that c was assigned before it was assigned.
Fortunately, this knowledge is not ported back to where it should happen but it's unsettling, and I can't rule out that we can prove something unexpected because of that.
I'm working on a fix because for referrers, we need to be able to know that when a variable is declared, it's not assigned yet.

What type of operating system are you experiencing the problem on?

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    during 3: execution of incorrect programAn bug in the verifier that allows Dafny to run a program that does not correctly implement its speckind: bugCrashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions