Skip to content

Regression on maintaining assertion in second half of constructors #6324

@robin-aws

Description

@robin-aws

Dafny version

4.10.0

Code to produce this issue

trait Validatable extends object { 

  ghost predicate Valid()
    reads Repr()

  ghost function Repr(): set<object> {
    {}
  }
}

class C {
  constructor (x: Validatable)
    requires x.Valid()
  {
    assert x.Valid();
    new;
    assert x.Valid();  // Fails
  }
}

Command to run and resulting output

% dafny verify regression.dfy
regression.dfy(17,4): Error: assertion might not hold
   |
17 |     assert x.Valid();  // Fails
   |     ^^^^^^

What happened?

Passes on Dafny 4.9.1.

Determined to be caused by this change: #5654

Can be worked around by adding assert unchanged(x.Repr()); before the line that failed.

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

Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    incompletenessThings that Dafny should be able to prove, but can'tkind: 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