This code
Null returnsNothing() {
}
Causes a hint about no return statement. This seems unnecessary.
Not to me.
A void function doesn't return anything. It can omit the return or use a return statement with no expression.
A non-void function returns something. It should use a return with an expression.
Trying to treat return; (or nothing) the same as return null; removes this distinction between a procedure/void function and an actual non-void function. Then you can argue that you should be able to use return; in all functions, as a shorthand for return null;, and I don't want that.
Basically I want return; and exit-with-no-return to act like an implicit return of type void, not of type Null.
What the current specification states is that it is a static warning for a return; in a synchronous, non-generator, non-generative-constructor function if the return type of the function isn't assignable to void (which means void or dynamic in Dart 1, probably just void in Dart 2).
I agree, void has since become a very common/standard return type. I vote Analyzer should continue marking this as missing_return.
Most helpful comment
Not to me.
A void function doesn't return anything. It can omit the return or use a return statement with no expression.
A non-void function returns something. It should use a return with an expression.
Trying to treat
return;(or nothing) the same asreturn null;removes this distinction between a procedure/void function and an actual non-void function. Then you can argue that you should be able to usereturn;in all functions, as a shorthand forreturn null;, and I don't want that.Basically I want
return;and exit-with-no-return to act like an implicit return of typevoid, not of typeNull.What the current specification states is that it is a static warning for a
return;in a synchronous, non-generator, non-generative-constructor function if the return type of the function isn't assignable tovoid(which meansvoidordynamicin Dart 1, probably justvoidin Dart 2).