Skip to content

Analyzer: Wrong error message about async return type #41670

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

Closed
eernstg opened this issue Apr 27, 2020 · 1 comment
Closed

Analyzer: Wrong error message about async return type #41670

eernstg opened this issue Apr 27, 2020 · 1 comment
Assignees
Labels
improve-diagnostics Related to the quality of diagnostic messages legacy-area-analyzer Use area-devexp instead.

Comments

@eernstg
Copy link
Member

eernstg commented Apr 27, 2020

Consider the following library:

Future<bool> f() async => Future<int>.value(42);

dartanalyzer --enable-experiment=non-nullable from commit d5310cb (of today) responds with the following error message:

ERROR|STATIC_TYPE_WARNING|RETURN_OF_INVALID_TYPE|/usr/local/google/home/eernst/lang/dart/scratch/202004/n039.dart|1|27|21|A value of type 'int' can't be returned from function 'f' because it has a return type of 'bool'.

This error message indicates that the return type of f is bool, but it is actually declared as Future<bool>, so that error message needs to be adjusted. The same behavior exists also without --enable-experiment=non-nullable.

Discussions about async returns are ongoing, cf. dart-lang/language#941. However, I do not think that the outcome of that PR will invalidate a fix for this issue.

@scheglov
Copy link
Contributor

With 0861470 analyzer now reports:
ERROR|STATIC_TYPE_WARNING|RETURN_OF_INVALID_TYPE|/Users/scheglov/dart/test/bin/test.dart|1|27|21|A value of type 'Future<int>' can't be returned from function 'f' because it has a return type of 'Future<bool>'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve-diagnostics Related to the quality of diagnostic messages legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

2 participants