[Issue 3922] Refuse returning nonvoid from void functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 5 15:36:23 PST 2012


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



--- Comment #9 from bearophile_hugs at eml.cc 2012-01-05 15:36:21 PST ---
The main real problem (returning a non void from a void function) is now fixed:
https://github.com/D-Programming-Language/dmd/commit/c942d51c8b1103d5ce4c3dfc03ae77c07c687cd6

-----------------

DMD 2.058head accepts code like this:


void foo() {
    return;
}
void main() {
    return foo();
}


This code is formally correct, because no real value is ignored.

I don't like such code a lot because that code looks like the intent of the
programmer is to return something, while this is not true. Maybe allowing this
is useful for generic code, I don't know. I'd like to see examples of this
usefulness in real code.

(But this discussion looks a bit different from the main issue that is now
fixed, so maybe this should be moved to a new different Bugzilla issue).

-- 
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