Void issues in dev.69.1

91 views
Skip to first unread message

mfair...@google.com

unread,
Jul 20, 2018, 7:42:01 PM7/20/18
to Dart Misc
TLDR:  The versions of dart2js and dart in dev-69.1 issue some incorrect errors around void.  These should be fixed in dev-69.2.

In the latest dev build (dart 2.0.0-dev.69.1), void usage errors are now enforced reported before running your dart programs:

void f() {}
print(f()); // error, you can't use the result of f()!

These have been reported in the analyzer for a few months now, and we believe this will catch bugs in your code and is a good change.

Unfortunately there were some bugs in the new voidness checks that are stricter than we had originally decided to do. Here are some examples:

  Future f() async => voidFn(); // Inadvent error
  when(voidFn()).thenReturn(...); // Inadvertent error
  run(() { return voidFn(); }); // Inadvertent error

And some of these issues affect the package ecosystem:

  package:analyzer must be upgraded to 0.32.4
  package:coveralls is currently not in a workable state

This change has been rolled back and will be fixed in dev-69.2, which should be released shortly. In the meantime you can use dev.69.0, or you can, if you wish, fix your code to comply with the extra strict errors. However be aware that these will not be required after the next release.

There is one new error which you may newly see which is likely to be kept for dart 2, which you may also see. This was not reported before due to a bug:

  void f() async {} // an async function that you should not await
  await f(); // this is now reported as an error

If you have issues with this in your package, please let us know.

We recognize that the current state of void errors is a bit confusing with this release, compared to old ones, and trying to predict what that means going forward. Please reach out to me if you have any questions! mfair...@google.com

Patrice Chalin

unread,
Jul 24, 2018, 6:34:22 AM7/24/18
to Dart Misc
On Friday, July 20, 2018 at 7:42:01 PM UTC-4, mfair...@google.com wrote:
TLDR:  The versions of dart2js and dart in dev-69.1 issue some incorrect errors around void.  These should be fixed in dev-69.2.

Hi Mike: you wrote "should be fixed in dev-69.2". Can you confirm whether the fix made it into dev-69.2? Thanks, Patrice

In the latest dev build (dart 2.0.0-dev.69.1), void usage errors are now enforced reported before running your dart programs:

void f() {}
print(f()); // error, you can't use the result of f()!

These have been reported in the analyzer for a few months now, and we believe this will catch bugs in your code and is a good change.

Unfortunately there were some bugs in the new voidness checks that are stricter than we had originally decided to do. Here are some examples:

  Future f() async => voidFn(); // Inadvent error
  when(voidFn()).thenReturn(...); // Inadvertent error
  run(() { return voidFn(); }); // Inadvertent error

And some of these issues affect the package ecosystem:

  package:analyzer must be upgraded to 0.32.4
  package:coveralls is currently not in a workable state

This change has been rolled back and will be fixed in dev-69.2, which should be released shortly. In the meantime you can use dev.69.0, or you can, if you wish, fix your code to comply with the extra strict errors. However be aware that these will not be required after the next release.

There is one new error which you may newly see which is likely to be kept for dart 2, which you may also see. This was not reported before due to a bug:

  void f() async {} // an async function that you should not await
  await f(); // this is now reported as an error

If you have issues with this in your package, please let us know.

...

William Hesse

unread,
Jul 24, 2018, 9:22:23 AM7/24/18
to Dart Misc
The fixes for this did make it into dev-69.2.
I have not verified them in that version.


On Friday, July 20, 2018 at 7:42:01 PM UTC-4, mfair...@google.com wrote:
Reply all
Reply to author
Forward
0 new messages