-
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
Fixing some semantic model and refactoring issues with deconstruction #12381
Changes from all commits
432135a
0860351
fd3eaa2
8a9fa3a
6ef0517
dbddd6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,6 +255,19 @@ public override BoundNode VisitBinaryOperator(BoundBinaryOperator node) | |
throw ExceptionUtilities.Unreachable; | ||
} | ||
|
||
public override BoundNode VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What is the reason for this? I'm not as familiar with the node map so it's unclear why we have this behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The node map allows mapping from syntax back to bound node. But the bound nodes for deconstruction hold more information than is typical, such as deconstruction steps, conversion and assignment steps. Those don't map directly to syntax though, and so should not appear in the map for the semantic model to understand the syntax. |
||
{ | ||
// For deconstruction declarations, the BoundLocals in the LeftVariables should not be added to the map | ||
if (!node.IsDeclaration) | ||
{ | ||
VisitList(node.LeftVariables); | ||
} | ||
|
||
Visit(node.Right); | ||
// don't map the deconstruction, conversion or assignment steps | ||
return null; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems like all of our testing for the node map is indirect. Instead of actually querying to see if the value is in the map, we use an IDE feature that happens to call into the node map. Is it possible to test this directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most direct test is via |
||
|
||
protected override bool ConvertInsufficientExecutionStackExceptionToCancelledByStackGuardException() | ||
{ | ||
return false; | ||
|
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.
What does this field represent? Don't we have a separate BoundLocalDeconstructionDeclaration node to represent declarations?
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.
We do have a separate node for d-declaration which is a statement. But all it contains is a
BoundDeconstructionAssignmentOperator
.The problem is that in the case of an assignment that is not a declaration, the expressions on the LHS should make it into the node map. But in the case of a declaration, they should not.
For comparison, if you have
x = 1;
, you will have 3 nodes in the node map: one for the whole assignment expression, one for the value1
and one for the localx
.But if you have
var x = 1
, then you will have a different set of 3 nodes: one for the whole statement, one for the value1
and one for the typevar
. But nox
.