Skip to content

Crash when using method named this[] in metadata #83610

@jcouv

Description

@jcouv

The following test asserts in debug mode and crashes in release mode:
System.InvalidCastException : Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol' to type 'Microsoft.CodeAnalysis.CSharp.Symbols.PropertySymbol'.

    [Fact]
    public void Indexing_51()
    {
        //public class C
        //{
        //    public void 'this[]' () { }
        //}
        var ilSrc = """
.class public auto ansi beforefieldinit C
    extends System.Object
{
    .method public hidebysig instance void 'this[]' () cil managed
    {
        ret
    }

    .method public hidebysig specialname rtspecialname instance void .ctor () cil managed
    {
        IL_0000: ldarg.0
        IL_0001: call instance void [mscorlib]System.Object::.ctor()
        IL_0006: nop
        IL_0007: ret
    }
}
""";

        var src = """
_ = new C()[43];
""";

        CreateCompilationWithIL(src, ilSrc).VerifyEmitDiagnostics();
    }

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions