Confusing error message when a void
value is used #56992
Open
Description
FutureOr<void> foo() => print(""); // print() returns void
The code above produces an error in both analyzer and VM. Analyzer error message is A value of type 'void' can't be returned from the function 'foo' because it has a return type of 'FutureOr<void>'
and VM error is Error: A value of type 'void' can't be returned from a function with return type 'FutureOr<void>'.
This error message is confusing. void
is assignable to FutureOr<void>
, the problem here is that a void
value returned by print()
is used. Please update the error message accordingly.
cc @eernstg
Dart SDK version: 3.7.0-71.0.dev (dev) (Fri Oct 25 17:06:43 2024 -0700) on "windows_x64"