Skip to content

Confusing error message when a void value is used #56992

Open
@sgrekhov

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"

Metadata

Assignees

No one assigned

    Labels

    area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).improve-diagnosticsRelated to the quality of diagnostic messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions