Skip to content

Analyzer throws a compile error when async function with Future<bool> return type returns dynamic. #42237

Closed
@iarkh

Description

@iarkh

Dart VM version: 2.9.0-13.0.dev (dev) (Fri May 29 15:59:05 2020 +0200) on "windows_x64"

This issue is related with SDK Issues #41266, #41437, as well as with co19 issues #603 and 703.

It is similar with #42236, but it's agains analyzer, not dart.

Seems like after the #941 the following code should not throw compile error:

import "dart:async";
dynamic getNull() => null;
Future<bool> test1() async => await getNull();
main() {}

However, still dartanalyzer behaves in such a way.

Sample output is:

$> dartanalyzer --enable-experiment=non-nullable test.dart
Analyzing test.dart...
error - A value of type 'dynamic' can't be returned from function 'test1' because it has a return type of 'Future'. - test.dart:3:31 - return_of_invalid_type
1 error found.

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD Releaselegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions