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

Making assertions explicit fails for nested statements #4016

Closed
MikaelMayer opened this issue May 15, 2023 · 0 comments · Fixed by #4169
Closed

Making assertions explicit fails for nested statements #4016

MikaelMayer opened this issue May 15, 2023 · 0 comments · Fixed by #4169
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part:implicit-assertions

Comments

@MikaelMayer
Copy link
Member

Dafny version

4.1.0

Code to produce this issue

datatype D = C(value: int) | N

function Test(e: D, inputs: map<int, int>): bool {
  match e
  case N => true
  case C(index) => inputs[index] == index
}

Command to run and resulting output

Paste this code in VSCode, click on input[index], select "Insert explicit failing assertion", it will modify the code incorrectly.

What happened?

Here is the wrong result. index#Z should be replaced by index

datatype D = C(value: int) | N

function Test(e: D, inputs: map<int, int>): bool {
  match e
  case N => true
  case C(index) => assert index#Z in inputs;
                   inputs[index] == index
}

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

Windows

@MikaelMayer MikaelMayer added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label May 15, 2023
MikaelMayer added a commit that referenced this issue Jun 22, 2023
This PR fixes #4016
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>
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 part:implicit-assertions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant