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

Disambiguation for zero- and one-element positional patterns #36515

Closed
gafter opened this issue Jun 17, 2019 · 1 comment
Closed

Disambiguation for zero- and one-element positional patterns #36515

gafter opened this issue Jun 17, 2019 · 1 comment

Comments

@gafter
Copy link
Member

gafter commented Jun 17, 2019

From today's LDM:

Pattern-Matching

Nople pattern syntax

Is () OK as a zero-element positional pattern? Is var () OK?

Resolution: Yes for both. To be scheduled.

Oneple pattern syntax

We previously said that a type is required in a positional pattern with one element. But that doesn't work as a disambiguation.

What about this

  bool M(SomeTypeThatImplementsItuple it) => it is WhatType(3) {P:4};

Here, what type could we possibly write if we are trying to match using ITuple?

I think a better disambiguation rule is to require a property subpattern (even if the empty {}) whenever a positional pattern has only one nested pattern and no type.

Approved (resolution): the presence of a property part disambiguates from an expression even without a type. To be scheduled.

@gafter gafter self-assigned this Jun 17, 2019
@gafter gafter added this to the Compiler.Next milestone Jul 9, 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 23, 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 7, 2020

Implemented in #40543

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

1 participant