dotnet/roslyn

VB.NET AnalyzeDataFlow incorrectly reports parameters as WrittenInside

Open

#68.286 geöffnet am 22. Mai 2023

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-CompilersBughelp wanted

Repository-Metriken

Stars
 (20.414 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Version Used: 4.6.0

Steps to Reproduce:

Use following source code to analyse

Public Sub Test(i As Integer)
    Dim s = i.ToString()
End Sub

with following visitor

public override SyntaxNode VisitMethodBlock(MethodBlockSyntax node)
{
    var first = node.Statements.First();
    var last = node.Statements.Last();
    var dataFlow = semanticModel.AnalyzeDataFlow(first, last);
    Debug.Assert(dataFlow.WrittenInside.Length == 1);

    return node;
}

Expected Behavior: dataFlow.WrittenInside should not contain Parameter i As System.Int32, only Local s As System.String

Actual Behavior: dataFlow.WrittenInside contains Parameter i As System.Int32.

Notes: Equivalent code in C# is analysed as expected, the parameter is not part of the dataFlow.WrittenInside.

I suspect this line: https://github.com/dotnet/roslyn/blob/687921ffae8ad91a5464473cb1759fd463c345f2/src/Compilers/VisualBasic/Portable/Analysis/FlowAnalysis/DataFlowPass.vb#L1537

Contributor Guide