dotnet / linker

389 stars 126 forks source link

Analyzer produces incomplete set of warnings for conditional control flow with arrays #3047

Open jkurdek opened 2 years ago

jkurdek commented 2 years ago
void TestMergedArrayElementWithUnknownIndex (int i)
{
    Type[] arr = new Type[] { null };
    if (i == 1)
        arr[0] = GetMethods (); // PublicMethods
    else
        arr[i] = GetFields (); // UnknownValue
    arr[0].RequiresAll (); // Should produce 2 warnings IL2062 and IL2072, analyzer issues only IL2062
}

Test comes from ArrayDataFlow.cs

The multi value at array's index 0 should contain two values after the merge, one coming from the if branch, and the other resulting from assigning the value at unknown index in the else branch. Thus 2 warnings should be produced.

The analyzer only produces the warning corresponding to assigning the value at unknown index.