Skip to content

Improve error messages when variable designation is in incorrect order with property pattern #50220

@Youssef1313

Description

@Youssef1313

Version Used:

master

Steps to Reproduce:

public class C
{
    public void M(object o)
    {
        if (o is string s { Length: 5 }) { }
    }
}

SharpLab.

Expected Behavior:

A more clear error message

Actual Behavior:

error CS1026: ) expected
error CS1002: ; expected
error CS1513: } expected

Alternative:

Allow the variable designation to come either before or after the property patterns.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions