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

Refining a module with a class containing opaque functions causes resolution error #4315

Closed
EkanshdeepGupta opened this issue Jul 20, 2023 · 0 comments · Fixed by #4319
Closed
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@EkanshdeepGupta
Copy link
Collaborator

Dafny version

4.2.0

Code to produce this issue

module M1 {
  class C {
    opaque function f() : bool { true }
  }
}

module M2 refines M1 {
}

Command to run and resulting output

$ ./Binaries/Dafny verify ~/test/scratch.dfy
    |
173 | <nonexistent line>
    |                     ^

/Users/ekanshdg/test/scratch.dfy[M2](173,20): Error: 'this' is not allowed in a 'static' context
1 resolution/type errors detected in scratch.dfy

What happened?

Due to the change making reveal lemmas static, there is a resolution error when the static reveal lemma tries to set the fuel for its non-static originating function. This only gets triggered when a module is resolved again, like when it is being refined, because the reveal lemma is added after the resolution is complete.

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

Mac

@EkanshdeepGupta EkanshdeepGupta added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Jul 20, 2023
EkanshdeepGupta added a commit that referenced this issue Jul 21, 2023
EkanshdeepGupta added a commit that referenced this issue Jul 21, 2023
EkanshdeepGupta added a commit that referenced this issue Jul 21, 2023
EkanshdeepGupta added a commit that referenced this issue Jul 21, 2023
MikaelMayer pushed a commit that referenced this issue Jul 26, 2023
…ginal procedures (#4319)

This PR fixes #4315
I added the corresponding 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>
keyboardDrummer pushed a commit to keyboardDrummer/dafny that referenced this issue Sep 15, 2023
…static original procedures (dafny-lang#4319)

This PR fixes dafny-lang#4315
I added the corresponding 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>
RustanLeino added a commit that referenced this issue Nov 2, 2023
PR #4180 introduced the ability
to `reveal` an instance function in a static context. In the recent PR
#4498, this has been implemented
to put the instance function itself, without a receiver argument, into
an attribute. The recent PR then special-cases the resolution of that
attribute. I would call that a hack.

This PR mimics that hack for the new resolver. That makes
`git-issue-4315.dfy` (see Issue
#4315) pass with both
resolvers.

The hack introduced in this PR and in
#4498 is not a great idea,
because a use of `this` is placed into the AST in a context where there
is no `this`. If (rather, when) this gets fixed, it should be fixed in
both resolvers.

### How has this been tested?

Test `git-issues/git-issue-4315.dfy` has been converted to run with both
the old and new resolver.

<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
Projects
None yet
1 participant