[dart-announce] Breaking Change: --preview-dart-2 will be turned on by default

116 views
Skip to first unread message

'Kevin Moore' via Dart Announcements

unread,
May 30, 2018, 6:15:37 PM5/30/18
to Dart Announcements

tl;dr

  • As part of releasing Dart 2, we will be enabling --preview-dart-2 by default in our dev channel releases. This may cause some breakages due to stricter Dart type enforcement.

  • The change will land soon in the Dart 2 dev channel.

  • Keep reading to understand how this may affect your code and how to address issues.

Introduction

In February, the Dart team announced Dart 2, and we offered steps to preview Dart 2 features via the --preview-dart-2 flag. We are now ready to enable this flag by default. If you have not already tested your apps and packages with this flag, please do so now to see if you are impacted.

Breaking changes

Changes to Dart 2’s type system include a compile-time and runtime checks.

  • The Dart Analyzer has already been enforcing Dart 2 compile-time checks for some time, so we don’t anticipate any significant breakages.

  • The Dart Dev Compiler (DDC) and Flutter have been enforcing Dart 2 runtime checks, so code that has been run and tested with these tools should also seen few issues.

  • You may, however, see new errors as we are enable runtime checks in the Dart VM and dart2js.

How do I fix my code?

How can I get help?


A reply will be posted to this thread when the release has landed.

--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Announcements" group.
Visit this group at https://groups.google.com/a/dartlang.org/group/announce/.

Natalie Weizenbaum

unread,
May 31, 2018, 12:41:44 PM5/31/18
to General Dart Discussion, announce
What does "land soon" mean? How long do users have to get their packages working in Dart 2 mode?

How do users ensure their code will be compatible with Dart 2 mode? The Dart 2 migration guide doesn't mention anything about --preview-dart-2. How can a user run all their package's tests in Dart 2 mode?

You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/13b39623-f197-4a60-a875-a1b1ff032176%40dartlang.org.

Natalie Weizenbaum

unread,
Jun 4, 2018, 4:55:26 PM6/4/18
to General Dart Discussion
Ping?

Nate Bosch

unread,
Jun 4, 2018, 7:15:43 PM6/4/18
to General Dart Discussion
On Mon, Jun 4, 2018 at 1:55 PM 'Natalie Weizenbaum' via Dart Misc <mi...@dartlang.org> wrote:
Ping?

On Thu, May 31, 2018 at 12:41 PM Natalie Weizenbaum <nw...@google.com> wrote:
What does "land soon" mean?

I think the goal is this week.
 
How long do users have to get their packages working in Dart 2 mode?

As long as they are willing to hold off updating to the next drop of the SDK. For at least a while it should also be possible to run with `DART_VM_OPTION=--no-preview-dart-2` to get the latest SDK but keep using Dart 1 runtime semantics in the VM.
 

How do users ensure their code will be compatible with Dart 2 mode? The Dart 2 migration guide doesn't mention anything about --preview-dart-2. How can a user run all their package's tests in Dart 2 mode?

Might be an oversight of the migration guide but for VM tests the approach is `DART_VM_OPTIONS=--preview-dart-2 pub run test`. For dart2js tests the approach is adding `--preview-dart-2` to the dart2js_args in `build.yaml` and running tests with `pub run build_runner test -- -p chrome`. I don't _think_ `pub run test` supports passing flags to dart2js.

I think the pattern we expect most projects to take is - upgrade to the latest SDK, try to run tests, fix failures. As an escape hatch to get unblocked the fallbacks are `--no-preview-dart-2` or downgrading to an older SDK.
 

Natalie Weizenbaum

unread,
Jun 5, 2018, 12:15:18 PM6/5/18
to General Dart Discussion
On Mon, Jun 4, 2018 at 7:15 PM 'Nate Bosch' via Dart Misc <mi...@dartlang.org> wrote:
On Thu, May 31, 2018 at 12:41 PM Natalie Weizenbaum <nw...@google.com> wrote:
What does "land soon" mean?

I think the goal is this week.

That gives users essentially no time to ensure their code doesn't break, especially since they didn't have migration instructions until just now.
 
How long do users have to get their packages working in Dart 2 mode?

As long as they are willing to hold off updating to the next drop of the SDK. For at least a while it should also be possible to run with `DART_VM_OPTION=--no-preview-dart-2` to get the latest SDK but keep using Dart 1 runtime semantics in the VM.

This answer only makes sense for application authors. Package authors need to make sure their code will work for their downstream users, which means they need time to ensure compatibility before backwards-incompatible changes land for everyone by default.
 
How do users ensure their code will be compatible with Dart 2 mode? The Dart 2 migration guide doesn't mention anything about --preview-dart-2. How can a user run all their package's tests in Dart 2 mode?

Might be an oversight of the migration guide but for VM tests the approach is `DART_VM_OPTIONS=--preview-dart-2 pub run test`. For dart2js tests the approach is adding `--preview-dart-2` to the dart2js_args in `build.yaml` and running tests with `pub run build_runner test -- -p chrome`. I don't _think_ `pub run test` supports passing flags to dart2js.

I think the pattern we expect most projects to take is - upgrade to the latest SDK, try to run tests, fix failures. As an escape hatch to get unblocked the fallbacks are `--no-preview-dart-2` or downgrading to an older SDK.

Again, package authors need to be able to ensure compatibility before their users get breaking SDKs, and they need time to migrate before their users start breaking. They also need (documented, straightforward) continuous integration support so that they can ensure that their code won't start breaking when they add new changes.

Kevin Moore

unread,
Jun 6, 2018, 7:37:36 PM6/6/18
to Dart Misc
We've been clear from the beginning that there may be breaking changes in Dart 2 -dev releases at any point.

If a user hits an issue with a specific release, they can always rollback to a version that doesn't have breaks.

The value of front loading this change and the associated pain will help us fix issues to ensure the gold release is higher quality.
Reply all
Reply to author
Forward
0 new messages