dotnet/roslyn

Unclear CS0252 (Possible unintended reference comparison)

Aperta

#58.996 aperta il 21 gen 2022

 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Version Used:

17.1.0 P1.1

Steps to Reproduce:

using System;

public class C
{
    public void M(Action x, Action y)
    {
        _ = (MulticastDelegate)x == y;
    }
}

Expected Behavior:

Either no warning, or a more clear warning.

Actual Behavior:

warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'MulticastDelegate'

Guida contributor