33798260d6
Change-Id: I781aabc6acc4f0341659380ed6cd169d66edce4e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425346 Commit-Queue: Lasse Nielsen <lrn@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com>
39 lines
1.0 KiB
Dart
39 lines
1.0 KiB
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] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
await v;
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
await vs[0];
|
|
// ^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
|
|
// ^
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
var v2 = vs[0];
|
|
await v2;
|
|
// ^^
|
|
// [analyzer] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
|
|
// [cfe] This expression has type 'void' and can't be used.
|
|
|
|
// A `FutureOr<void>` can be awaited.
|
|
await fov;
|
|
}
|