[Issue 3922] Refuse returning nonvoid from void functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 6 06:28:42 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=3922



--- Comment #13 from timon.gehr at gmx.ch 2012-01-06 06:28:39 PST ---
(In reply to comment #12)
> (In reply to comment #10)
> > This is required for forwarding and cannot change.
> > 
> > auto foo(T...)(T args){return bar(args);}
> 
> Well couldn't this special case be checked?
> Accidentally turning the return type into void

Who on earth accidentally changes a function's return type? Also, if the
function does not actually return void, a compile error results.

> or forgetting to change the type
> from void after you added a return x; is much more common than such code imho.

That will give a compile error already. (unless x is a property function
returning void)

> Also should a function returning something or not really depend on argument
> types?

You realize that it is already disallowed to return non-void from a function
returning void? The only case that is allowed and should stay allowed is
something like this:

void bar(){...}
void foo(){return bar();}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list