Skip to content

unawaited_futures false negative for FutureOr #59105

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

Open
FMorschel opened this issue Apr 6, 2023 · 1 comment
Open

unawaited_futures false negative for FutureOr #59105

FMorschel opened this issue Apr 6, 2023 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-negative P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FMorschel
Copy link
Contributor

Describe the issue
unawaited_futures not linting with FutureOr

To Reproduce
Add the lint to analysis_options.yaml and run the following:

void main() async {
  futureOrFunc(); //Nothing
  futureFunc(); //Linted
}

Future<void> futureFunc() async {}

FutureOr<void> futureOrFunc() async {}

Expected behavior
I expected the linter to warn me about FutureOr Functions so that I only process things after the previous lines have been processed.

@FMorschel FMorschel changed the title unawaited_futures false negative unawaited_futures false negative for FutureOr Apr 6, 2023
@keertip keertip added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Apr 12, 2023
@lrhn
Copy link
Member

lrhn commented Apr 12, 2023

The current description of unawaited_futures only say that it warns about things with type Future, not FutureOr.

So it's doing what it claims it's doing.
It's not unreasonable to want to always await a FutureOr too, but be aware that unawaited only accepts a Future as argument, so you can't do unawaited(futureOrFunc()); to disable a lint applying to FutureOrs.

@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-negative P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants