Skip to content

Allow "void" as a generic type parameter. #17518

Closed
@lrhn

Description

@lrhn

The void type is only allowed as a function return type. It is equivalent to "Null" except for documentation purposes (and allowing "return;" statements in the body).
The documentation meaning is that the function does not return a meaningful value, and its result shouldn't be used.

For Future, we have the same documentation need. Some Futures carry no meaningful value, they are effectively the delayed results of evaluating a void function.
It would improve documentation if these futures could be typed as "Future<void>". By duality, it would be equivalent to "Future<Null>", but documenting a different intent.

It's likely to also be useful in other places. Perhaps we should allow "void" everywhere we currently allow "dynamic".

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing reporttype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions