mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:59:47 +00:00
665c58aa1a
Closes #41602 Change-Id: I29b8880e3fdb769b2acdf2c82a9ced038d7b0d94 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149287 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
39 lines
926 B
Dart
39 lines
926 B
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Test that it is an error to await an expression of type `void`.
|
|
|
|
import "dart:async";
|
|
|
|
void v;
|
|
List<void> vs = [null];
|
|
FutureOr<void> fov;
|
|
|
|
void main() async {
|
|
await print('');
|
|
// ^
|
|
// [analyzer] unspecified
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
await v;
|
|
// ^
|
|
// [analyzer] unspecified
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
await vs[0];
|
|
// ^
|
|
// [analyzer] unspecified
|
|
// ^
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
var v2 = vs[0];
|
|
await v2;
|
|
// ^
|
|
// [analyzer] unspecified
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
// A `FutureOr<void>` can be awaited.
|
|
await fov;
|
|
}
|