Skip to content

Weird long #3361

@CreateAndInject

Description

@CreateAndInject

Original:

using System;

internal class Program
{
    static void Main(string[] args)
    {
        My my = new My();
        switch (my)
        {
            case 1:
                Console.WriteLine(1);
                break;
            case 2:
                Console.WriteLine(2);
                break;
            case 3:
                Console.WriteLine(3);
                break;
        }
        Console.WriteLine("Hello World!");
    }

}

public class My
{
    public static implicit operator int(My my)
    {
        return 0;
    }
}

ILSpy

private static void Main(string[] args)
{
	My my = new My();
	switch (my)
	{
	case 1L: // Compiler Error CS0266, why is it a long?
		Console.WriteLine(1);
		break;
	case 2L:
		Console.WriteLine(2);
		break;
	case 3L:
		Console.WriteLine(3);
		break;
	}
	Console.WriteLine("Hello World!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDecompilerThe decompiler engine itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions