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

Verification error on repeating method specification from trait #6038

Open
robin-aws opened this issue Jan 10, 2025 · 0 comments
Open

Verification error on repeating method specification from trait #6038

robin-aws opened this issue Jan 10, 2025 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label release-blocker Must be resolved before the next release

Comments

@robin-aws
Copy link
Member

robin-aws commented Jan 10, 2025

Dafny version

latest master (regression since 4.9.1)

Code to produce this issue

trait T {

  ghost function Modifies(): set<object>

  method Foo()
    modifies Modifies()
}

class C extends T {

  const Repr: set<object>

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

  // Error: method might modify an object not in the parent trait context's modifies clause
  method Foo()
    modifies Modifies()
}

Command to run and resulting output

% dafny verify github-issue-XXX.dfy 
github-issue-XXX.dfy(17,9): Error: method might modify an object not in the parent trait context's modifies clause
   |
17 |   method Foo()
   |   ^^^^^^^^^^^^


Dafny program verifier finished with 1 verified, 1 error

What happened?

The example verifies successfully on Dafny 4.9.1. I suspect this is a consequence of the recent change to CanCall but haven't confirmed yet. It seems to have something to do with invoking a trait function within the modifies clause.

Having trouble seeing a workaround, and even if there is one, it's really unfortunate that simply repeating the definition from a trait in a class doesn't verify without help.

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

Mac

@robin-aws robin-aws added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label release-blocker Must be resolved before the next release labels Jan 10, 2025
typerSniper added a commit that referenced this issue Jan 11, 2025
<!-- Please remove these Markdown comments before publishing this PR,
since the PR message is often used as the commit description.
We only allow squash merging and GH suggests the PR details as a default
commit message. -->

The PR fixes the this [git
issue](#6038) which describes
how verification fails when repeating the method specification from
trait. This completeness bug which arose because can calls were not
emitted for modifies clauses of methods during their override checks.


<!-- Is this a user-visible change? Remember to update RELEASE_NOTES.md
-->

### How has this been tested?
<!-- Tests can be added to
`Source/IntegrationTests/TestFiles/LitTests/LitTest/` or to
`Source/*.Test/…` and run with `dotnet test` -->

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label release-blocker Must be resolved before the next release
Projects
None yet
Development

No branches or pull requests

1 participant