dotnet/roslyn
Vedi su GitHubVB local lowering improperly visits nodes that it synthesizes itself
Open
#4684 aperta il 20 ago 2015
Area-CompilersBugConcept-Design Debthelp wanted
Metriche repository
- Star
- (20.414 star)
- Metriche merge PR
- (Merge medio 6g 17h) (256 PR mergiate in 30 g)
Descrizione
The Roslyn VB compiler's lowering phase has lots of places where it builds a node and then lowers it. The design guidelines are that subexpressions are visited first (once) and then an appropriate node is built over it (and not visited). Generally speaking nodes that are built by the lowering phase should never be visited by the lowering phase. If further transformation are required then the appropriate helper should be called directly.
Here is one example of this antipattern in the code:
' create assignment operator
Dim assignmentOperator As BoundExpression = New BoundAssignmentOperator(node.Syntax, assignmentTarget,
valueBeingAssigned, True)
' if there are any temporaries, wrap it in
If temporaries IsNot Nothing Then
If temporaries.Count > 0 Then
assignmentOperator = New BoundSequence(node.Syntax,
StaticCast(Of LocalSymbol).From(temporaries.ToImmutableAndFree()),
ImmutableArray.Create(Of BoundExpression)(assignmentOperator),
Nothing,
If(assignmentOperator.Type.IsVoidType(),
assignmentOperator.Type,
Compilation.GetSpecialType(SpecialType.System_Void)))
Else
temporaries.Free()
End If
End If
' create assignment statement
Return Visit(New BoundExpressionStatement(node.Syntax, assignmentOperator))
Migrated from TFS/DevDiv 1040877