Skip to content

warning on missing await in non-async function. #58512

@bsutton

Description

@bsutton

I have a problem with the following code:

void recreateDir(String path)  {
  deleteDir(path);
  createDir(path);
}

Future<void> deleteDir(String path) async {};

Future<void> createDir(String path) async {};

Dart will happily let me call async functions from a non-async function without awaiting them.

In the above example it is problematic to call createDir before deleteDir which may occur if they are unawaited.

If the method createDir is async and I use the lint 'unawaited_futures' I get an appropriate warning.
However if I forget to add the async keyword to the createDir signature then I have a serious problem and no warning.

We need a lint to warn of the above issue.
The above example is a mistake that I make regularly in my own code and its rather hard to debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-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