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

Enable CS8073 in a warning wave #45744

Closed
gafter opened this issue Jul 7, 2020 · 0 comments · Fixed by #45750
Closed

Enable CS8073 in a warning wave #45744

gafter opened this issue Jul 7, 2020 · 0 comments · Fixed by #45750
Assignees
Labels
Area-Compilers Feature - Warning Waves Warning Waves Feature Request Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@gafter
Copy link
Member

gafter commented Jul 7, 2020

CS8073 applies in a scenario such as this:

class Program
{
    public static void M(S s)
    {
        if (s == null) { } // CS8073
        if (s != null) { } // CS8073
    }
}
struct S
{
    public static bool operator==(S s1, S s2) => false;
    public static bool operator!=(S s1, S s2) => true;
    public override bool Equals(object other) => false;
    public override int GetHashCode() => 0;
}
(6,13): warning CS8073: The result of the expression is always 'false' since a value of type 'S' is never equal to 'null' of type 'S?'
(7,13): warning CS8073: The result of the expression is always 'true' since a value of type 'S' is never equal to 'null' of type 'S?'

The compiler currently only produces this warning in "strict" mode. As part of the warning wave feature, this warning should be included in warning wave "5".

@gafter gafter self-assigned this Jul 7, 2020
@gafter gafter added this to the 16.8 milestone Jul 7, 2020
gafter pushed a commit to gafter/roslyn that referenced this issue Jul 7, 2020
@gafter gafter added the 4 - In Review A fix for the issue is submitted for review. label Jul 7, 2020
@ghost ghost closed this as completed in #45750 Jul 16, 2020
@sharwell sharwell added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed 4 - In Review A fix for the issue is submitted for review. labels Aug 10, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Warning Waves Warning Waves Feature Request Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants