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 #3322: Add missing checks for equality comparison #3368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

siegfriedpammer
Copy link
Member

No description provided.

&& (conversions.IdentityConversion(lhsType, rhsType)
|| conversions.ExplicitConversion(lhsType, rhsType).IsReferenceConversion
|| conversions.IdentityConversion(rhsType, lhsType)
|| conversions.ExplicitConversion(rhsType, lhsType).IsReferenceConversion))
Copy link
Member

Choose a reason for hiding this comment

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

Is this condition coming from some spec?
I think this might be overly restrictive; wasn't if (obj == 42) also allowed (with a warning)?
Though I guess being overly restrictive here will just result in some harmless redundant casts.

Copy link
Member

Choose a reason for hiding this comment

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

Btw identity conversions are always symmetric, so if you already checked IdentityConversion(lhsType, rhsType) you don't need to also check IdentityConversion(rhsType, lhsType), as that will always have the same result.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

2 participants