Skip to content

unawaited_futures should consider try {return future} as unawaited #59489

Closed
@rrousselGit

Description

@rrousselGit

Describe the issue
When returning a Future inside async functions, when wrapped in a try block, that future won't trigger an unawaited lint

To Reproduce

Future<void> fn() async {
  try {
    return Future.value();
  } catch (e) {
    ...
  }
}

Expected behavior

The return future line should emit an unawaited_futures. And awaiting it or marking it as unawaited should make the issue disappear.

Additional context

This is a common mistake. The catch/finally blocks may not trigger correctly when the returned future is unawaited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestdevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-negativetype-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