Bug 4186 – Forward reference error from static function with no return type
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-05-14T04:59:00Z
Last change time
2015-06-09T05:13:46Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-05-14T04:59:19Z
This is D2 code:
static foo() {
return 1.0;
}
enum double x = foo(); // line 4
void main() {}
dmd v2.045 shows at compile time:
test.d(4): Error: forward reference to foo
The error message is wrong in two ways:
- It doesn't show the error of the missing return type of foo at line 1
- There is a forward reference error that D isn't supposed to generate here
Comment #1 by r.sagitario — 2010-05-14T09:11:21Z
The static without return type implies "auto". This is a variation of bug 2810, and the patch there also fixes this testcase.
*** This issue has been marked as a duplicate of issue 2810 ***