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 issues with diagnostic deduplication #36825

Merged
merged 4 commits into from
Apr 2, 2025
Merged

fix issues with diagnostic deduplication #36825

merged 4 commits into from
Apr 2, 2025

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Apr 2, 2025

Non-comparable diagnostics were being adding multiple times to the final output, and would also panic in the equality comparison when encountering nil values.

The comparison of hcl diagnostics was incorrectly comparing missing Source values, but we can't compare location if it does not exist. This may present a problem with tests relying on DiagnosticComparer which is using Equals, but since hcl diagnostics should generally not exist without a source it is probably OK in practice.

We were also comparing diagnostics with Extra data as equal, but Extra values can be any type, and are only asserted by interface by the party expecting that interface, so we can't attempt to compare them for equality.

Non-comparable diagnostics were being adding multiple times, which might
also panic in the equality comparison
@jbardin jbardin added no-changelog-needed Add this to your PR if the change does not require a changelog entry 1.12-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged labels Apr 2, 2025
@jbardin jbardin requested a review from a team as a code owner April 2, 2025 13:58
dsa0x
dsa0x previously approved these changes Apr 2, 2025
@jbardin
Copy link
Member Author

jbardin commented Apr 2, 2025

Found another incorrect comparison for equality, so updated the PR

mildwonkey
mildwonkey previously approved these changes Apr 2, 2025
jbardin added 3 commits April 2, 2025 12:09
Extra values can be any type, and are only asserted by interface by the
party expecting that interface so we can't attempt to compare them for
equality.

The only diagnostic type with Extra values which implements Equals is
and hcl diagnostic.
The source check was skipped if either value was nil, but we can't be
sure they are equal if there is no value. This may prove to be
problematic is tests, as diagnostic equality for deduplication isn't
strict equality, but rather relies on being able to prove the context is
also equal.
@jbardin jbardin merged commit 87cdcc3 into main Apr 2, 2025
8 checks passed
@jbardin jbardin deleted the jbardin/diag-dedupe branch April 2, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.12-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants