Open
Description
The following function:
int foo({int? arg}) {
arg = 0;
return (() => arg)();
}
Produces this error:
error • A value of type 'int?' can't be returned from the function 'foo' because it has a return type of 'int'. • test.dart:3:10 • return_of_invalid_type
Despite the fact that arg
will clearly always be non-null when it's returned. There's not even a hypothetical risk that arg
will be reassigned to null
between the function being created and being invoked, since the non-nullable assignment appears before the function is created and no nullable assignments exist anywhere.