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

Handle array type patterns in switch statements #40149

Closed
gafter opened this issue Dec 5, 2019 · 1 comment
Closed

Handle array type patterns in switch statements #40149

gafter opened this issue Dec 5, 2019 · 1 comment

Comments

@gafter
Copy link
Member

gafter commented Dec 5, 2019

In the proposed changes for C# 9.0, a type expression such as A[] can in theory be used as a switch case.

    case A[]:

However, it is likely that this will parse as an expression. The binder should be flexible enough to take the parse tree (for the expression) and bind it as a type, and the pattern binder should be capable of backing off from the expression interpretation to the type interpretation.

Similarly

    case (A[]):

This should have the same meaning as above, but currently parses as an erroneous cast expression.

@gafter gafter added this to the Compiler.Next milestone Dec 5, 2019
@gafter gafter self-assigned this Dec 5, 2019
@gafter gafter modified the milestones: Compiler.Next, Compiler.Net5 Dec 11, 2019
gafter added a commit to gafter/roslyn that referenced this issue Dec 19, 2019
gafter pushed a commit that referenced this issue Jan 6, 2020
…40503)

Fixes #40149
Relates to #40727 (test plan for C# 8 patterns)

* Add tests for zero and one element positional patterns
Related to #36515
@gafter
Copy link
Member Author

gafter commented Jan 6, 2020

Fixed in #40503

@gafter gafter closed this as completed Jan 6, 2020
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