Skip to content

Analyzer should warn when using constant-update-2018 features with an SDK constraint that does not guarantee support #36296

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
4 of 5 tasks
stereotype441 opened this issue Mar 21, 2019 · 7 comments
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Milestone

Comments

@stereotype441
Copy link
Member

stereotype441 commented Mar 21, 2019

The first version of Dart with constant-update-2018 enabled is planned to be 2.2.2, so we should implement a hint based on checking the user's SDK constraint against this version number.

Since the constant-update-2018 feature affects both syntax and semantics, it will be more challenging to detect when the user is inadvertently taking advantage of the feature. We will definitely detect the easy cases. We'll detect the harder cases if time allows.

The easy cases are as follows:

  • Making use of is or as in a constant context.
  • Using or overriding the new >>> operator.
  • Applying one of the operators &, |, or ^ to operands of type bool.

The harder cases are as follows (they require some rework of the analyzer's constant evaluator):

  • When using == in a constant, a non-primitive type is compared to null.
  • When using &&, ||, ??, or ?: in a constant, an operand fails to be a valid constant, but it's permitted by constant-update-2018 because that operand is skipped due to short-circuiting.

Note that constant-update-2018 also makes subtle changes to what is considered a valid "potentially constant" expression. We're not going to try to account for this, because we believe such differences will be extremely rare corner cases.

@stereotype441 stereotype441 added legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Mar 21, 2019
@stereotype441 stereotype441 added this to the Dart2.3 milestone Mar 21, 2019
@stereotype441 stereotype441 added P1 A high priority bug; for example, a single project is unusable or has many test failures and removed P2 A bug or feature request we're likely to work on labels Mar 22, 2019
@bwilkerson
Copy link
Member

Initial work done in https://dart-review.googlesource.com/c/sdk/+/97567.

@bwilkerson
Copy link
Member

I believe that we have the functionality required for 2.3, and a little more, so I'm removing the milestone.

@bwilkerson bwilkerson removed this from the Dart2.3 milestone Mar 26, 2019
@stereotype441 stereotype441 added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 4, 2019
@bwilkerson bwilkerson removed their assignment Apr 29, 2019
@stereotype441 stereotype441 added this to the D24 Release milestone May 30, 2019
@stereotype441
Copy link
Member Author

We need to update this warning to refer to version 2.3.2.

@bwilkerson bwilkerson self-assigned this May 30, 2019
@bwilkerson
Copy link
Member

Should this include the >>> operator?

@stereotype441
Copy link
Member Author

Should this include the >>> operator?

No, >>> is slated for a future release.

Thanks for taking this on, Brian!

@bwilkerson
Copy link
Member

@bwilkerson bwilkerson removed their assignment May 30, 2019
@stereotype441
Copy link
Member Author

As of 556c913, the warning now refers to version 2.3.2. The remaining bullet item is a small enough corner case that it's not worth putting effort into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants