System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.VisitLambdaOrFunction(IBoundLambdaOrFunction node)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.VisitLambda(BoundLambda node)
at Microsoft.CodeAnalysis.CSharp.BoundLambda.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitConversion(BoundConversion node)
at Microsoft.CodeAnalysis.CSharp.BoundConversion.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitCall(BoundCall node)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.VisitCall(BoundCall node)
at Microsoft.CodeAnalysis.CSharp.BoundCall.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitBinaryOperator(BoundBinaryOperator node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperator.VisitBinaryOperator(BoundBinaryOperator node)
at Microsoft.CodeAnalysis.CSharp.BoundBinaryOperator.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitCall(BoundCall node)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.VisitCall(BoundCall node)
at Microsoft.CodeAnalysis.CSharp.BoundCall.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitExpressionStatement(BoundExpressionStatement node)
at Microsoft.CodeAnalysis.CSharp.BoundExpressionStatement.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitSequencePoint(BoundSequencePoint node)
at Microsoft.CodeAnalysis.CSharp.BoundSequencePoint.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitList[T](ImmutableArray`1 list)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.VisitBlock(BoundBlock node)
at Microsoft.CodeAnalysis.CSharp.BoundBlock.Accept(BoundTreeVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.Visit(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Analysis.Analyze(BoundNode node)
at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Rewrite(BoundStatement loweredBody, NamedTypeSymbol thisType, ParameterSymbol thisParameter, MethodSymbol method, Int32 methodOrdinal, MethodSymbol substitutedSourceMethod, ArrayBuilder`1 lambdaDebugInfoBuilder, ArrayBuilder`1 closureDebugInfoBuilder, VariableSlotAllocator slotAllocatorOpt, TypeCompilationState compilationState, DiagnosticBag diagnostics, HashSet`1 assignLocals)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.LowerBodyOrInitializer(MethodSymbol method, Int32 methodOrdinal, BoundStatement body, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState, Boolean instrumentForDynamicAnalysis, DebugDocumentProvider debugDocumentProvider, ImmutableArray`1& dynamicAnalysisSpans, DiagnosticBag diagnostics, VariableSlotAllocator& lazyVariableSlotAllocator, ArrayBuilder`1 lambdaDebugInfoBuilder, ArrayBuilder`1 closureDebugInfoBuilder, StateMachineTypeSymbol& stateMachineTypeOpt)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0()
at Roslyn.Utilities.UICultureUtilities.<>c__DisplayClass5_0.<WithCurrentUICulture>b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.WaitForWorkers()
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean emitTestCoverageData, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, Boolean emitMetadataOnly, Boolean emitTestCoverageData, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream, Stream metadataPEStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, CompilationTestData testData, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, Stream metadataPEStream, CancellationToken cancellationToken)
Version Used: 2.3.2
Steps to Reproduce:
https://sharplab.io/#v2:D4AQDABCCMDcCwAoJIDMUBMEAqBTAzgC4QDeSEFU6IALBALIAUAlKeZR4QBYCW+A2iwgBeAHwQwAXQgBqYRDjsKAXyUQ1aCDwB2xbn34gArAB4dhcQDNpZRBw4BzXMRJQA7BNgRVd+xXzOpD4cPspAA=
Expected Behavior:
Code is compiled correctly.
Actual Behavior:
Note that
masterhas a different (but similar) error:System.ArgumentException: adding a duplicate.See: https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4AEAMACFBGA3AWACgiUBmLAJgwBU5YMBvIjFrclAFgwFkAKASkbNWImAAsAllADaAjAF4AfBjQBdDAGp5GPMJYBfPRiNkMEgHYwM4qdJQBWADwWYygGbqmhESIDmcKwYsAHYVXAxDbx8WKADGSJFI/SA===