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

function refinement broken #5366

Open
erniecohen opened this issue Apr 25, 2024 · 2 comments
Open

function refinement broken #5366

erniecohen opened this issue Apr 25, 2024 · 2 comments
Labels
area: refinement Dafny's module-refinement machinery during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking priority: next Will consider working on this after in progress work is done

Comments

@erniecohen
Copy link

erniecohen commented Apr 25, 2024

Dafny version

4.5.0, 4.6.0, nightly

Code to produce this issue

abstract module A {
  function F(x: int): (r: int)
    ensures r > x
}

module B refines A {
  function F ... 
  // the result type of function 'F' (bool) differs from the result type of the corresponding function in the module it refines (int)
  // function 'F' is declared with a different number of parameter (0 instead of 1) than the corresponding function in the module it refines
  { x + 1 }
}

Command to run and resulting output

vscode

What happened?

The example above from the manual fails in the resolver. It worked through 4.4.0.

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

Mac

@erniecohen erniecohen added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Apr 25, 2024
@keyboardDrummer keyboardDrummer added during 2: compilation of correct program Dafny rejects a valid program during compilation priority: next Will consider working on this after in progress work is done and removed during 2: compilation of correct program Dafny rejects a valid program during compilation labels Apr 26, 2024
@keyboardDrummer
Copy link
Member

The documentation seems to indicate this should work, although I'm not used to this syntax either:

image

We could check with @RustanLeino to see whether he intends to keep the semantics as the documentation currently defines it.

@keyboardDrummer keyboardDrummer added part: resolver Resolution and typechecking area: refinement Dafny's module-refinement machinery labels Apr 29, 2024
@erniecohen
Copy link
Author

erniecohen commented Apr 29, 2024

A workaround is to skip the refinement notation, e.g.

module B refines A {
  function F(x: int): (r: int)
  { x + 1 }
}

Note that if the refined module defines a precondition, you cannot repeat this precondition in the refining module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: refinement Dafny's module-refinement machinery during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking priority: next Will consider working on this after in progress work is done
Projects
None yet
Development

No branches or pull requests

2 participants