D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4186 - Forward reference error from static function with no return type
Summary: Forward reference error from static function with no return type
Status: RESOLVED DUPLICATE of issue 2810
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-14 04:59 UTC by bearophile_hugs
Modified: 2015-06-09 05:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-05-14 04:59:19 UTC
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 Rainer Schuetze 2010-05-14 09:11:21 UTC
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 ***