Skip to content

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
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2025

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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