-
Notifications
You must be signed in to change notification settings - Fork 2
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
FEA-2496: Fixed Cascade Indexing #84
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
if (node.parent is CompoundAssignmentExpression) { | ||
final assignmentNode = node.parent as CompoundAssignmentExpression; | ||
element = assignmentNode.readElement ?? assignmentNode.writeElement; | ||
if (element == null) { | ||
final assignmentExpr = | ||
node.thisOrAncestorOfType<CompoundAssignmentExpression>(); | ||
if (assignmentExpr == null) return; | ||
|
||
element = assignmentExpr.readElement ?? assignmentExpr.writeElement; | ||
} |
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.
Given the following dart code:
Foo()..value = 1;
This is what the generated ast results in
Foo()..value = 1; (ExpressionStatement)
Foo()..value = 1 (CascadeExpression)
Foo() (MethodInvocation)
Foo (SimpleIdentifier)
() (ArgumentList)
..value = 1 (AssignmentExpression) <----- (extends from CompoundAssignmentExpression)
..value (PropertyAccess)
value (SimpleIdentifier)
1 (IntegerLiteral)
Given the above code, value (SimpleIdentifier)
is the case that makes it to this conditional. If we refer to the ast, the parent of this element is PropertyAccess
, not CompoundAssignmentExpression
, which tells us this expression can occur at multiple depths, not just the parent
We can solve this by just searching for the closest node of the specific type, and treat that as the assignment expression we care about
QA +1
|
🚀 @Workiva/release-management-p 🚢 |
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.
+1 from RM
FEA-2496
Closes #80