Skip to content

Await void #28305

Closed
Closed
@munificent

Description

@munificent

This code doesn't contain any static warnings:

void returnsVoid() {}

main() async {
  await returnsVoid();
}

Should it? It seems like code that is awaiting an immediate value is likely to be an error. Code that is awaiting void is really likely to be an error.

This cropped in internally because someone was doing:

await stuff.forEach((element) => convert it to a future...);

Instead of using forEach() they should have used map().

cc @floitschG @eernstg @lrhn @leafpetersen @bwilkerson

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).language-strong-mode-polish

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions