dotnet / dotnet/linker

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

Open
#3,047 0 comments 0 reactions 0 assignees View on GitHub
area-Linker: DataFlow
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

```c#
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](https://github.com/dotnet/linker/blob/main/test/Mono.Linker.Tests.Cases/DataFlow/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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.