Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pattern parsing #282

Open
tamasvajk opened this issue Jan 12, 2023 · 2 comments
Open

Improve pattern parsing #282

tamasvajk opened this issue Jan 12, 2023 · 2 comments

Comments

@tamasvajk
Copy link
Collaborator

tamasvajk commented Jan 12, 2023

The below code reports parsing errors in the recursive patterns R(E.A), R(E.A or E.B), (E.A):

void M(R expr)
{
    var x = expr is R(E.A) v0;
    var y = expr is R(E.A or E.B) v1;
    var z = expr is (E.A or E.B) v2;
}

record R(E e) { }
enum E { A, B }

This is a recurring coding pattern in Roslyn.

@tamasvajk
Copy link
Collaborator Author

There's no parse error for

void M()
{
    var a = expr switch
    {
        R(E.A) => 1
    };
}

So the above might be related to is [pattern].

At the same time, the sample added to this comment produces incorrect AST for the pattern:

(switch_expression_arm [4, 8] - [4, 19]
  (constant_pattern [4, 8] - [4, 14]
    (invocation_expression [4, 8] - [4, 14]
      function: (identifier [4, 8] - [4, 9])
      arguments: (argument_list [4, 9] - [4, 14]
        (argument [4, 10] - [4, 13]
          (member_access_expression [4, 10] - [4, 13]
            expression: (identifier [4, 10] - [4, 11])
            name: (identifier [4, 12] - [4, 13]))))))

The pattern should be a recursive pattern and not a constant one.

@vanessa-rodrigues
Copy link

Are there any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants