inference_ failure_ on_ function_ return_ type
Details about the 'inference_failure_on_function_return_type' diagnostic produced by the Dart analyzer.
The return type of '{0}' can't be inferred.
Description
#The analyzer produces this diagnostic when:
-
the language option
strict-inferenceis enabled in the analysis options file, - the declaration of a method or function has no return type, and
- the return type can't be inferred.
Example
#Given an analysis options file containing the following:
yaml
analyzer:
language:
strict-inference: true
The following code produces this diagnostic because the method
m doesn't have a return type:
dart
class C {
m() => 7;
}
Common fixes
#Add a return type to the method or function:
dart
class C {
int m() => 7;
}
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.