-
Notifications
You must be signed in to change notification settings - Fork 4.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
Deconstruction assignment: basic implementation #11290
Conversation
Tuple and underlying type unification. Part 1.
Tuple and underlying type unification. Part 2.
Tuple and underlying type unification. Part 3.
9528256
to
3d47b61
Compare
new BoundExpression[] { BindValue(arguments[0].Expression, diagnostics, BindValueKind.Assignment) } : | ||
SpecializedCollections.EmptyArray<BoundExpression>(); | ||
|
||
return BadExpression(node, args); |
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.
You forgot to bind the right-hand-side here.
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.
I'll stop by to ask you more about this.
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.
Done.
Btw, I started a new work items list for deconstructions: #11299. The known holes I'm tracking so far:
|
/// Replaces substitution currently used by the rewriter for a placeholder node with a different substitution. | ||
/// Asserts if there isn't already a substitution. | ||
/// </summary> | ||
private void UpdatePlaceholderReplacement(BoundValuePlaceholderBase placeholder, BoundExpression value) |
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.
Where is this used? It seems dangerous.
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.
The 'update' is not used yet. I'll remove.
🕐 |
I'm closing this PR and will create a new one for the features/tuples branch after I work out the parsing issue. |
Updating Features/tuples with latest from Future
3d47b61
to
33e78bd
Compare
26ca3ec
to
fa126d9
Compare
Here's a first basic implementation of deconstruction-assignment. I'm wondering if this should go into a feature branch instead as I only did limited IDE testing so far.
In terms of design:
BoundDeconstructionAssignmentOperator
). This bound node contains the list of variables on the left (bound and checked), the receiver forDeconstruct
, the symbol for theDeconstruct
method and information to complete the assignment of individual values (including conversions).-The
Deconstruct
method is resolved with restrictive rules at this point (we should find exactly one).Deconstruct
below),Deconstruct
with those out parameters,Vlad, the initial approach that we discussed for binding was very difficult (significant refactoring on tricky code). So the bound node holds onto the assignment expressions for each variable, as opposed to a Conversion object. Not only was this much simpler and natural, I think this will actually help later (when dealing with nesting case).
@dotnet/roslyn-compiler for review.