Skip to content

Pattern matching error leads to MSB6006 "csc.exe" exited with code -2146232797 #59804

@cluetjen

Description

@cluetjen

Invalid pattern matching in switch expression leads to csc.exe exited with code -2146232797 and does not show the real error in visual studio.

Steps to Reproduce:

  1. Add the following code to an empty project:
public class Class1
{
    public class Inner1
    {
    }
}

public class Class2
{
    public bool Test()
    {
        Class1 test = new Class1.Inner1();
        test switch
        {
            { Inner1: "" } => ""
        };
    }
}
  1. Build the project

Expected Behavior:
It should output an error that the {Inner1: ""} pattern is wrong.

Actual Behavior:
Compiler crashes and does not report the error.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions