Skip to content

AnalyzeDataFlow fails for InitializerExpressionSyntax if it is a child of an ArrayCreationExpressionSyntax #57572

@bernd5

Description

@bernd5

Version Used: commit 812a5c0

Steps to Reproduce:
Execute the following FlowTestBase test (or just query the dataflow)

[Fact]
public void TestDataFlowsArrayInit2()
{
    var analysis = CompileAndAnalyzeDataFlowExpression(@"
class C {
    public void F(int x)
    {
        int a = 1, y = 2;
        int[] b = new int[] /*<bind>*/{ a + x + 3 } /*</bind>*/;
        int c = a + 4 + y;
    }
}");
    Assert.Equal("x, a", GetSymbolNamesJoined(analysis.DataFlowsIn));
}

Expected Behavior:
The test should pass

Actual Behavior:
DataFlow.Success is false because NullableWalker does not Visit the array initializer which causes: "badregion".

Workaround:
We can just analyze the array creation itself - it has no impact on the result.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions