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

More relevant information on hovering failing assertions #3281

Closed
MikaelMayer opened this issue Dec 27, 2022 · 0 comments · Fixed by #3282
Closed

More relevant information on hovering failing assertions #3281

MikaelMayer opened this issue Dec 27, 2022 · 0 comments · Fixed by #3282
Labels
area: error-reporting Clarity of the error reporting kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: language server Support for LSP in Dafny (server part; client is in ide-vscode repo)

Comments

@MikaelMayer
Copy link
Member

Dafny version

3.10.0

Code to produce this issue

predicate P(i: int) {
  i <= 0
}

predicate Q(i: int, j: int) {
  i == j || -i == j
}

function method Toast(i: int): int
  requires P(i)

method Test(i: int) returns (j: nat)
  ensures Q(i, j)
{
  if i < 0 {
    return -i;
  } else {
    return Toast(i);
  }
}

Command to run and resulting output

Paste this code in VSCode.

If you hover over Q(i, j) (the failing postcondition), it does not tell you exactly which of the conjuncts of Q is failing
If you hover over the last "return" keyword, it just tell you that a postcondition is failing, but not which one.
If you hover over the call to Toast, it tells you that a function precondition might not hold, but it does not tell you which one.

What happened?

Currently, when we hover in the IDE an error message, we don't get all the related locations nor the related code.
Even worse, when we introduce a resolution error, hovering over it hides it under a potential ton of obsolete verification error. They should be removed from hovering.
All of this is extremely frustrating for a advanced Dafny developer like me, when using nested predicates, etc.
It could be marked as a "feature" but it's so frustrating that it was not taken account in the original design that I mark it as an error reporting bug.

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

Windows

@MikaelMayer MikaelMayer added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label area: error-reporting Clarity of the error reporting part: language server Support for LSP in Dafny (server part; client is in ide-vscode repo) labels Dec 27, 2022
keyboardDrummer pushed a commit that referenced this issue Jan 6, 2023
Fixes #3281 
Fixes dafny-lang/ide-vscode#335
Fixes dafny-lang/ide-vscode#317
Fixes dafny-lang/ide-vscode#210

Example code:
```dafny
predicate P(i: int) {
  i <= 0
}

predicate Q(i: int, j: int) {
  i == j || -i == j
}

function method Toast(i: int): int
  requires P(i)

method Test(i: int) returns (j: nat)
  ensures Q(i, j)
{
  if i < 0 {
    return -i;
  } else {
    return Toast(i);
  }
}
```

| Before: | After |
| --------|-------|
| Hovering Q(i,j)
![image](https://user-images.githubusercontent.com/3601079/209727765-e3c9c32b-dd27-4707-893b-8534b9ec0698.png)
|
![image](https://user-images.githubusercontent.com/3601079/209727590-2f833693-4b9d-44cf-afa8-fe43388e0c3d.png)
|
| Hovering the second return
![image](https://user-images.githubusercontent.com/3601079/209727748-5d291a36-7334-4b9c-8c08-c68718fd50f9.png)
|
![image](https://user-images.githubusercontent.com/3601079/209727565-19b8a1c6-0f78-41a3-ad85-7e0cbc1538c8.png)
|
| Hovering the call to Toast()
![image](https://user-images.githubusercontent.com/3601079/209727700-2e66f345-dd1f-47c5-92ce-cea811d2b8ce.png)
|
![image](https://user-images.githubusercontent.com/3601079/209727556-cbfe43c5-9fe2-49c9-a107-7111ef42b00c.png)
|
| Also, on the diagnostics side (and it's clickable!)
![image](https://user-images.githubusercontent.com/3601079/209844964-be5a31df-dddd-421a-937f-39a26fa8ce76.png)
|
![image](https://user-images.githubusercontent.com/3601079/209845060-09dd8fb5-5cd8-4e92-8302-beb93a837412.png)
|
| The resolver error appears after all obsolete verification
error<br>![image](https://user-images.githubusercontent.com/3601079/209727781-b3d88e9b-8bad-4e3b-b8fc-e9119837629e.png)
|
![image](https://user-images.githubusercontent.com/3601079/209728682-206bf18a-dfd8-40c5-a10d-8b5a4ccdd4c1.png)
|

I added language server tests and tested it in VSCode, and it works as
expected.

<!-- Are you moving a large amount of code? Read CONTRIBUTING.md to
learn how to do that while maintaining git history -->

<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
area: error-reporting Clarity of the error reporting kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: language server Support for LSP in Dafny (server part; client is in ide-vscode repo)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant