Could we make this work without errors and warnings?
Pike v8.1 release 9 running Hilfe v3.5 (Incremental Pike Frontend)
void foo() { } void bar() { return foo(); }
Compiler Warning: 1: Returning a void expression. Converted to zero. Compiler Error: 1: Wrong return type. Compiler Error: 1: Expected: void. Compiler Error: 1: Got : zero.
So the proposal is to change the compiler's handling of void in "return e" from this (pseudocode):
if ( typeof(e) == void ) { compile(evaluate side effects of e); warn("Returning a void expression. Converted to zero."); compile(return 0); }
to this:
if ( typeof(e) == void ) { compile(evaluate side effects of e); if ( return_type(this_function) == void ) { compile(return); } else { warn("Returning a void expression. Converted to zero."); compile(return 0); } }
? Seems reasonable to me.
Thanks. Lots of
if(whatever) { request->response_and_finish(args); return; }
will now be rewritten...
pike-devel@lists.lysator.liu.se