Skip to content

VB: Lambda in AsNew clause causes a crash in the compiler #53593

@tmat

Description

@tmat

Version Used:

Version 17.0.0 Preview 2.0 [31319.15.d17initial]

Steps to Reproduce:

Public Class C

    Dim a, b As New C((Function(n) n + 1)(1))

    Sub New(a As Integer) : End Sub
End Class

https://sharplab.io/#v2:DYLgbgRgPgkgtgBwPYCcAuBnABAZQJ4ZoCmcAsAFAAKArhMAJYDGWAwsAIYbYsUVb9YAIvThZ2AGiwQsAQWwA5IgHdWAClUAxagDtGaekm2rtASizasAaiwBGE6rsm+A5/xy0sipavazsMbWIAcyIUMxAsAFFtABNcWgpouLZODCA===

System.ArgumentException: An item with the same key has already been added. Key: Private Function (n As Object) As Object
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at Microsoft.CodeAnalysis.VisualBasic.LambdaRewriter.Analysis.VisitLambda(BoundLambda node, Boolean convertToExpressionTree)
   at Microsoft.CodeAnalysis.VisualBasic.LambdaRewriter.Analysis.VisitConversion(BoundConversion conversion)
   at Microsoft.CodeAnalysis.VisualBasic.BoundConversion.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitCall(BoundCall node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundCall.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitCall(BoundCall node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundCall.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitObjectCreationExpression(BoundObjectCreationExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundObjectCreationExpression.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitAssignmentOperator(BoundAssignmentOperator node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundAssignmentOperator.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitExpressionStatement(BoundExpressionStatement node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundExpressionStatement.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitSequencePoint(BoundSequencePoint node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundSequencePoint.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitStatementList(BoundStatementList node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundStatementList.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalker.VisitBlock(BoundBlock node)
   at Microsoft.CodeAnalysis.VisualBasic.LambdaRewriter.Analysis.VisitBlock(BoundBlock node)
   at Microsoft.CodeAnalysis.VisualBasic.BoundBlock.Accept(BoundTreeVisitor visitor)
   at Microsoft.CodeAnalysis.VisualBasic.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
   at Microsoft.CodeAnalysis.VisualBasic.LambdaRewriter.Analysis.Analyze(BoundNode node)

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