-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Open issue: list-pattern questions for 9/20/2021 #5201
Comments
Summary from LDM 9/22/2021:
|
So, not like a list of ranges would look then: |
It won't. ValueTuple is already a special case and doesn't use ITuple pattern semantics which only applies to a positional pattern on
I think this is intended to follow explicit/implicit null test design, however, it's different in that the designated value-set is causing the error, not the test itself so it's without precedents. This will need a proposal on how exactly we're going to achieve that and what is the expected behavior in various scenarios. |
We noticed. However, we didn't feel like it was worth adding a special case to list patterns to resolve the problems I mentioned.
@jcouv had some ideas on how we can modify the nonnegativeinteger value set. |
I'm happy to take a stab at the proposal to reduce |
And we'll have to be careful about when we warn. For example, |
confirm breaking change for property pattern Length/Count on countable/indexable type (non-negative assumption)
intArray is { Length: -1 }
// error CS8518: An expression of type 'int[]' can never match the provided pattern.confirm interaction between list-pattern and ITuple.
Proposal is to de-alias the elements, so
(1, 2, 3)
subsumes[1, 2, 3]
. The k-th element of anITuple
and the k-th element of the list are equivalent.If we do this, should we do it when the positional pattern works on the basis of
Deconstruct
?confirm that
[ .._ ]
requires a sliceable type, whereas[ 1, .. ]
doesn't."A slice_pattern with a subpattern is compatible with any type that is countable as well as sliceable."
confirm canonical formatting for slices
e is [ first, .. var rest ]
(space)e is [ first, ..var rest ]
(no space)gauge interest on some related features that might be considered for C# 11:
{ [0]: var x }
)re-iterate that we don't want/need a special length-pattern
{ length: ... }
(just useLength:
with new assumptions)Relates to championed issue #3435
Relates to test plan dotnet/roslyn#51289
The text was updated successfully, but these errors were encountered: