Skip to content
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

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

Closed
asashour opened this issue May 26, 2022 · 1 comment
Closed

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

asashour opened this issue May 26, 2022 · 1 comment
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta-recovery P2 A bug or feature request we're likely to work on

Comments

@asashour
Copy link
Contributor

asashour commented May 26, 2022

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 {

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 26, 2022
@bwilkerson bwilkerson added area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta-recovery labels May 26, 2022
@bwilkerson
Copy link
Member

@jensjoha

I believe that we need to have a consistent handling of await. As reported here, there are places where the parser is producing unexpected_token and places where it's allowing/requiring the analyzer to report the issue. It seems most consistent for the parser to always produce an await expression while parsing an expression and for those cases to always be handled by the analyzer. WDYT?

@johnniwinther johnniwinther added the P2 A bug or feature request we're likely to work on label May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta-recovery P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

5 participants