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

Fix: Removed wrong "related position" precision when dealing with regrouped quantifiers #4187

Merged

Conversation

MikaelMayer
Copy link
Member

This PR fixes #2211
After investigation it looks like the following expression

forall i | 0 <= i < |s| :: // Normal token
    && P1(s[i])
    && P2(s[i])

was split in two while searching for triggers

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:

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.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

RustanLeino
RustanLeino previously approved these changes Jun 23, 2023
Copy link
Collaborator

@RustanLeino RustanLeino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good description. From that description, this fix looks good.

Can you add another test that will exercise the is ExistsExpr branch of the code as well?

@MikaelMayer MikaelMayer self-assigned this Jun 27, 2023
@MikaelMayer
Copy link
Member Author

Thanks for the good description. From that description, this fix looks good.

Can you add another test that will exercise the is ExistsExpr branch of the code as well?

I added a test and verified that the output was different before this PR, it included the unwanted error location.

RustanLeino
RustanLeino previously approved these changes Jun 28, 2023
@MikaelMayer MikaelMayer enabled auto-merge (squash) July 5, 2023 20:53
@MikaelMayer MikaelMayer merged commit 58eff15 into master Jul 6, 2023
19 checks passed
@MikaelMayer MikaelMayer deleted the fix-2211-wrong-conjunct-mentioned-related-location-under branch July 6, 2023 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong conjunct mentioned in "related location" under a quantifier
2 participants