Skip to content

Analyzer: Wrong error message about async return type #41670

Closed
@eernstg

Description

@eernstg

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions