dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.1k stars 4.04k forks source link

Compiler Crash on Equality Comparison of a Tuple Casted from dynamic #76028

Open Jason5Lee opened 3 days ago

Jason5Lee commented 3 days ago

Version Used: .NET 9.0.0

Steps to Reproduce:

  1. Compile the following C# code (SharpLab Link):
    • The code involves casting a dynamic value to a tuple and performing an equality comparison on another tuple.
public class C {
    public static bool Test(dynamic o) =>
        (((int, int))o) == (2, 3);
}

Expected Behavior: The compiler compiles the code without crashes.

Actual Behavior:

jjonescz commented 16 hours ago
System.InvalidOperationException: Unexpected value 'ExplicitDynamic' of type 'Microsoft.CodeAnalysis.CSharp.ConversionKind'
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitConversion(BoundConversion conversion)