Skip to content

[Null-aware elements] Implement flow-analysis for null-aware map entires #56786

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

Closed
Tracked by #55949
chloestefantsova opened this issue Sep 25, 2024 · 0 comments
Closed
Tracked by #55949
Assignees
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). feature-null-aware-elements Implementation of the Null-aware elements feature implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)

Comments

@chloestefantsova
Copy link
Contributor

Since the control flow can be changed by the null-aware map entries, the shared flow analysis between the Analyzer and the CFE should be updated accordingly.

Consider the following code:

test1(String a, num x) {
  <String, dynamic>{?a: (x as int)};
  // `x` is promoted to `int`.
}

test2(String? a, num x) {
  <String, dynamic>{?a: (x as int)};
  // `x` is not promoted.
}

In test1 the flow analysis can establish that a is never a null, and the value of the null-aware map entry will always be evaluated; therefore, the promotion of x to int induced by the type cast should be visible below the line with the map literal. In contrast with that, in test2, the flow analysis can't establish that a will never be null, which makes it possible that in some cases x as int will not be executed at all; therefore, the variable x shouldn't be promoted below the line with the map literal.

@chloestefantsova chloestefantsova added area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) feature-null-aware-elements Implementation of the Null-aware elements feature labels Sep 25, 2024
@chloestefantsova chloestefantsova self-assigned this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). feature-null-aware-elements Implementation of the Null-aware elements feature implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)
Projects
None yet
Development

No branches or pull requests

1 participant