Skip to content

Specification inconsistency: await e with void expression #468

Closed
@eernstg

Description

@eernstg

The language specification specifies that await e is an error when e has static type void: There is a list of exceptions where a void expression can be used, and await e is not in this list.

However, this error was not implemented when Dart 2 was released, and we decided to allow await e even when e is void, in order to avoid a substantial amount of breakage. Cf. this comment and this one.

It may still be targeted using a --strict-await option on the analyzer, cf. dart-lang/sdk#33823, and the lint await_only_futures will also flag it.

This means that we should add await e as an additional exception in section Type Void, such that this is no longer an error. We may wish to mention that it is bad code, and there are ways to detect it (except that the spec doesn't otherwise mention lints).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions