commit | cb0eb28cbaedd032c234d3a5e372249603655765 | [log] [tgz] |
---|---|---|
author | Paul Berry <paulberry@google.com> | Wed May 10 19:31:19 2023 +0000 |
committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed May 10 19:31:19 2023 +0000 |
tree | 98713a7655094541a153f36288d7f59a2cc8ce20 | |
parent | 3ed8736bdd0d123a6d90f4471484bb9cf98dece5 [diff] |
Account for differing flow analysis conventions between CFE and shared code. With one exception (noted below), the shared analysis logic uses the convention that the expressions passed to flow analysis are the original (pre-lowered) expressions, whereas the expressions passed to flow analysis by the CFE are the lowered expressions. This difference caused two problems: - If a boolean expression appeared on the right hand side of a pattern assignment or pattern variable declaration, and it was lowered, the flow analysis implications of that boolean expression would be lost. - If a boolean expression appeared in a `when` clause, and it was lowered, the flow analysis implications of that boolean expression would be lost. Exception: for switch statements, the shared analysis logic has been passing lowered expressions to flow analysis, so this problem didn't occur for `when` clauses in switch statements. Notably, when compiling for the VM, the CFE lowers expressions like `x != null` to something more like `!(x == null)`. Fortunately, the first of these two situations shouldn't cause problems very often, since typically if the right hand side of an assignment or variable declaration is a boolean expression, there is no need for the left hand side to involve patterns. As for the second of these two situations, it's also not too likely to cause problems, since typically null checks occur inside patterns rather than in `when` clauses. As a short term fix, we remove the exception noted above, and we account for the difference in conventions by adding a call to `FlowAnalysis.forwardExpression` to the CFE's implementation of `dispatchExpression`, so that when transitioning between CFE logic and shared logic, flow analysis will be informed how to match up the lowered expressions to their pre-lowered counterparts. Longer term, I would like to switch everything to the convention of using the original (pre-lowered) expressions; this will bring the analyzer and CFE into better alignment with each other and should eliminate a class of subtle bugs. This long term goal is tracked in https://github.com/dart-lang/sdk/issues/52189. Fixes #52183. Fixes #52241. Bug: https://github.com/dart-lang/sdk/issues/52183, https://github.com/dart-lang/sdk/issues/52241. Change-Id: I2449ce34c54325603bc2730d1660a7cfc7d79aec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298840 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app.
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.