Skip to content
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

Merged
merged 9 commits into from
Sep 12, 2023
Merged

Conversation

matthewnitschke-wk
Copy link
Contributor

@matthewnitschke-wk matthewnitschke-wk commented Aug 15, 2023

FEA-2496

Issue Status

Closes #80

@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Comment on lines -118 to 124
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;
}
Copy link
Contributor Author

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

@matthewnitschke-wk matthewnitschke-wk changed the title Fixed issues with cascade references Fixed Cascade Indexing Sep 1, 2023
@matthewnitschke-wk matthewnitschke-wk marked this pull request as ready for review September 1, 2023 16:15
@bender-wk bender-wk changed the title Fixed Cascade Indexing FEA-2496: Fixed Cascade Indexing Sep 12, 2023
@matthewnitschke-wk
Copy link
Contributor Author

QA +1

  • Verified that snapshots resulted in correct results

@matthewnitschke-wk
Copy link
Contributor Author

🚀 @Workiva/release-management-p 🚢

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole3-wf rmconsole3-wf merged commit d8e02c4 into master Sep 12, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cascade values index incorrect reference
5 participants