Comment #8 on issue 17891 by
andrew.m...@gmail.com: A value of type 'void'
>> It would be helpful if you could take a look at the patch and offer some
>> suggestions on improving it, since as I said it only covers a small
>> portion of what we want it to do, at this time.
Your patch not looks inside the problem. It are not correct.
Problem in the (hard) language design.
Method that has the 'void' return type in Dart ALWAYS return a value.
This is a mistake to believe that in Dart some expression may not yield
value.
Method that has the 'void' return type is able to return value.
If it able to return value it always return value even it is not specified.
In Dart the default value for all object are "null" (bottom).
But at the same time:
- The name void does not denote a Type object.
- No instance ever has type void
So, in this case how we can display some warnings if "void" does not denote
a Type object and no instance ever has type void?
Example:
"A value of type 'void' cannot be assigned to a variable of type 'Object'"
This is the same as you warning "Train that can't swim underwater can not
run into space".
All type checks in Dart MUST know about special types such a 'void'.
They MUST take into account that these types does not denote a Type object
and no instance ever has these types.
How possible check types that denote type object with types that DOES NOT
denote type object?
Warning about type incompatibility in this case are not correct.
Instead of this message:
A value of type 'void' cannot be assigned to a variable of type 'Object'
Must be (because void does not denote a Type object):
The 'void' type cannot has instance and cannot be assigned to a variable of
type 'Object'.
The 'void' type does not denote type and cannot be assigned to a variable
of type 'Object'.
P.S.
But no one rule in Dart language spec states that void function does not
return (not yield) value.