Fix CFE legacy type promotion. The previous implementation of type promotion in the CFE was unsound, didn't follow the spec, and contained a lot of unnecessary logic related to experiments that eventually led to flow analysis. This change updates type promotion to be nearly spec compliant and removes most of the unnecessary logic. The lack of spec compliance went (astonishingly) unnoticed for over three years, probably mostly due to the fact that for the most part it promoted more eagerly than it should; as a result, any code that was erroneously accepted by the CFE was rejected by the analyzer. Unfortunately, in at least one case the erroneous promotion led to incorrect VM behavior (issue #43640). There's one aspect in which the CFE implementation is still not spec compliant. The spec says that when analyzing an expression `e1 && e2`, if `e2` shows that a variable `v` has type `T`, but `e1` assigns to `v`, then promotion does not occur. This turns out to be difficult to model in the existing architecture, since much of the type promotion logic happens during parsing, and any assignments that occur in `e1` are parsed prior to figuring out that a logical and is in progress. Fortunately, this is a rare circumstance, and allowing type promotion in this situation is sound, so it should not lead to incorrect VM behavior. Considering how long the other incorrect logic (which was much more severe) went unnoticed, it seems unlikely that it will cause problems for users. Bug: https://github.com/dart-lang/sdk/issues/43640 Change-Id: If97293733e64e286780de5079a703717b8f6f142 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166040 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Bob Nystrom <rnystrom@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, getting started, and more.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
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.