Skip to content

Wrong error in await e expression when e has type void #57065

@sgrekhov

Description

@sgrekhov

According to the Dart specification https://github.com/dart-lang/language/blob/48d3cbdb3dd4d75459453c69ef255064a4b89f13/specification/dartLangSpec.tex#L22709

The occurrence of an expression of type void is a compile-time error unless it is
permitted according to one of the following rules.
...

  • In an expression of the form await e, e may have type void.

But the code below produce compile-time errors in the both analyzer and CFE.

void foo() {}

main() async {
  void e = 0;
  await e; // Error: This expression has type 'void' and can't be used.
  await foo(); // Error: This expression has type 'void' and can't be used.
}

Dart SDK version: 3.7.0-99.0.dev (dev) (Mon Nov 4 08:02:58 2024 -0800) on "windows_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions