Skip to content

Specification inconsistency: await e with void expression #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eernstg opened this issue Jul 23, 2019 · 1 comment
Closed

Specification inconsistency: await e with void expression #468

eernstg opened this issue Jul 23, 2019 · 1 comment

Comments

@eernstg
Copy link
Member

eernstg commented Jul 23, 2019

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).

@eernstg
Copy link
Member Author

eernstg commented Aug 6, 2021

With null safety, await e is a compile-time error when e has static type void.

@eernstg eernstg closed this as completed Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant