[Issue 3922] Wrong error message with return in void function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 21 05:09:43 PDT 2010


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



--- Comment #3 from bearophile_hugs at eml.cc 2010-08-21 05:09:39 PDT ---
Those error messages I have suggested are wrong, because using return in a void
function is OK:


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


It seems that this too is allowed:


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


What's wrong is returning something that is not void from a void function. So a
better error message is needed.


So for this wrong code:

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


A possible message:
temp.d(2): Error: a void function can return void only.

Alternative:
temp.d(2): Error: a void function can't return an int.

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