Skip to content

Partial indexer with an IndexerName attribute causes a crash in compiler #76842

@AlekseyTs

Description

@AlekseyTs

https://sharplab.io/#v2:EYLgtghglgdgNAFxFANnAJiA1AHwAIAMABHgIwB0ASgK4wJRgCm5AwgPZgAOqjATgMp8AblADGjAM4BuALAAoeZwi96EFEQkJe1UQiL9S8gN7yiZkgGYiSlVDVFYehAAsoEgNqOiADwC6RIwBzRgQAXgA+bykAX3lTc3cASRh0Rm8+ADkIJgAKACIAWQBPLKY8gEpfeLM8KxtVdS8XN086H38gkJj5WLkgA= :

using System.Runtime.CompilerServices;

partial struct S1
{
    public partial int this[int x] {get=>x;}

    [IndexerName("MyName")]
    public partial int this[int x] {get;}
}

Or https://sharplab.io/#v2:EYLgtghglgdgNAFxFANnAJiA1AHwAIAMABHgIwB0ASgK4wJRgCm5AwgPZgAOqjATgMp8AblADGjAM4BuALAAoeZwi96EFEQkJe1UQiL9S8gN7yiZogG0AkjHSMAHnwByEJgAoARAFkAni6YeAJQAuqbmeADMREoqUGpEsHoIABZQEhaJRPbBREYA5owIALwAfPZSAL7yYWaR0cqq6pkpaRl0WTn5hZXyVXJAA=== :

using System.Runtime.CompilerServices;

partial struct S1
{
    [IndexerName("MyName")]
    public partial int this[int x] {get=>x;}

    public partial int this[int x] {get;}
}

Observed:

System.ArgumentException: adding a duplicate (Parameter 'key')
   at Roslyn.Utilities.ConcurrentDictionaryExtensions.Add[K,V](ConcurrentDictionary`2 dict, K key, V value) in /_/src/Compilers/Core/Portable/InternalUtilities/ConcurrentDictionaryExtensions.cs:line 24
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) in /_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs:line 1343
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) in /_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs:line 537
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass25_0.<CompileNamedTypeAsync>b__0() in /_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs:line 439
   at Roslyn.Utilities.UICultureUtilities.<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() in /_/src/Compilers/Core/Portable/InternalUtilities/UICultureUtilities.cs:line 139
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__292_0(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean hasDeclarationErrors, Boolean emitMethodBodies, BindingDiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in /_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs:line 160
   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, RebuildData rebuildData, CompilationTestData testData, CancellationToken cancellationToken) in /_/src/Compilers/Core/Portable/Compilation/Compilation.cs:line 2970

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions