-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Explainer for list-patterns #57210
Explainer for list-patterns #57210
Conversation
return null; | ||
} | ||
|
||
var indexes = new Dictionary<int, string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not know you were working on this. I took a different approach to handle trailing patterns. Updated #55327 just in case. We should def go with your change since this is closer to completion. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I got a bit excited this weekend and gave it a try. Thanks
I'll probably steal some bits from your draft
{ | ||
switch (eval) | ||
{ | ||
case BoundDagPropertyEvaluation e when e.IsLengthOrCount: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unlikely to have multiple length tests in the shortest path. I suspect this doesn't need to be in the loop.
indexes.Add(e.Index, subPattern); | ||
} | ||
break; | ||
case BoundDagSliceEvaluation e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may produce multiple slice patterns in the list but since we won't construct a dag for invalid patterns that probably won't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we don't get here when multiple slices. Added test
tryHandleRecursivePattern(ref unnamedEnumValue) ?? | ||
tryHandleListPattern(ref unnamedEnumValue) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this after recursive patterns will make it unnecessary to worry about []
or [..]
but we may choose to generate those instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that something I've been debating. Should we say { Length: 0 }
or []
?
7c98d01
to
89edb85
Compare
From offline chat, closing in favor of #55327 |
Co-authored-by: Julien Couvreur <jcouv@users.noreply.github.com>
Still work-in-progress (one test hits assertion, some tests remaining to add)
Relates to test plan #51289
FYI @alrz