Skip to content

[analyzer] AWAIT_IN_WRONG_CONTEXT is not triggered in if condition #49116

@asashour

Description

@asashour
Future<bool> doSomething() async => true;

void f1() {
  if (await doSomething()) {}
}

void f2() {
  await doSomething();
}

In f1(), the error message is Unexpected text 'await', which denotes that AWAIT_IN_WRONG_CONTEXT is not reported.

In f2() the error message is correct, and there is a fix to add async.

Once this is fixed, the proposed fix for #49114 chould also be enhanced to add async if the method is not already async.


Possibly related failing test:

@failingTest
test_sync() async {

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.legacy-area-front-endLegacy: Use area-dart-model instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions