Bug 3855 – Misleading error messages for return expression in void methods.
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2010-02-25T12:45:00Z
Last change time
2014-02-15T02:28:32Z
Assigned to
nobody
Creator
sky
Comments
Comment #0 by sky — 2010-02-25T12:45:45Z
dmd 1.056 gives a misleading error message on invalid code.
The error was not even reported in my previous version (1.045).
Consider the following invalid code:
class C {
int i;
void m() {
return i;
}
}
And output of "dmd main.d":
main.d(4): Error: dotvar has no effect in expression (this.i)
The error message could be much clearer about not being able to return something for a void method.
Testing the same thing with a simple function:
void m() {
return 1;
}
gives the following output of "dmd main.d":
main.d(2): Error: long has no effect in expression (1)
Which is still not very clear.
Comment #1 by yebblies — 2011-06-12T23:18:46Z
*** This issue has been marked as a duplicate of issue 3746 ***