-
Notifications
You must be signed in to change notification settings - Fork 262
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
Wrong conjunct mentioned in "related location" under a quantifier #2211
Comments
Thanks for reporting this issue ! |
Not sure. Like I said, I have a feeling that this used to work, because it is somewhat fundamental to my workflow when I use Dafny, and I would have noticed it before if it was broken. But these days I only use Dafny to answer stack overflow questions, so it's hard for me to know exactly when it broke. I suppose I will try to find some time to do a git bisect. |
I confirm that the behavior was the same in Dafny 3.1.0 |
And you don't need |
If you split the forall, I confirm that the error reporting works as expected. (forall i | 0 <= i < |s| ::
P1(s[i]))
&& (forall i | 0 <= i < |s| :: // Related location 3
P2(s[i])) // Related location 4 What you demonstrate is clearly an error in error reporting. |
Right. I should have mentioned that I put the |
Ok, I used Clément's new script to try all previous releases, and it turns out I was wrong. This behavior goes back to at least v1.9.9. |
Slightly simpler example predicate P1(a: int)
predicate P2(a: int)
method M()
requires forall i :: P1(i)
//requires forall i :: P2(i)
ensures forall i ::
(P1(i) || false) // related location
&& (P2(i) || false)
{} |
…rouped quantifiers (#4187) This PR fixes #2211 After investigation it looks like the following expression ```dafny forall i | 0 <= i < |s| :: // Normal token && P1(s[i]) && P2(s[i]) ``` was split in two while searching for triggers ```dafny forall i | 0 <= i < |s| :: // Nested token, outer pointing to "forall", inner pointing to "P1" P1(s[i]) forall i | 0 <= i < |s| :: // Nested token, outer pointing to "forall", inner pointing to "P2" P2(s[i]) ``` But another pass for searching for triggers regroups quantifiers which have the same bound variables and same triggers. Since the two expressions have the same trigger s[i], they are regroupped with an AND back to: ```dafny forall i | 0 <= i < |s| :: // Nested token, outer pointing to "forall", inner pointing to "P1" P1(s[i]) && P2(s[i]) ``` As you can see, the problem of the regrouping is that it takes the token of the first element of the group, which had an indication that it pointed to P1. The last related location of #2211 thus was an artefact of the token being copied without paying attention to that detail. Since we regroup the tokens, there is no nested token there to have so this PR removes nested tokens when regrouping comprehensions to avoid giving false information. <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>
Consider this Dafny program.
The method
M
has an error because it is missing the commented-out precondition aboutP2
. But Dafny reports the following error misleading messages:The last "Related location" points to the first conjunct (the 14th character on the 6th line), but in fact the first conjunct is true and the problem is with the second conjunct.
On the other hand, Dafny behaves correctly when not under a quantifier, as in this example:
which generates
The 25th character of the 5th line correctly points to the third conjunct, because the first two are true.
This is a relatively serious usability issue, and I feel like it is a regression that used to work?
I reproduced this error on the main branch.
The text was updated successfully, but these errors were encountered: