I tried this on the DMD64 D compiler v2.059 on linux. The valid D code at the
bottom fails with the following errors when I invoke
--------------------
$ rdmd static_if_bug.d
static_if_bug.d(15): Error: undefined identifier 'foo'
--------------------
Commenting out either "Bug trigger" below results in a successful compilation.
--------------------
struct Klass {
double value;
//static const Klass zero; // Does not trigger bug!
static const Klass zero = {0}; // Bug trigger #1
static if (true) // Bug trigger #2
static if (true)
Klass foo() { return Klass(); }
}
void main() {
auto a = Klass().foo();
}
--------------------
Comment #1 by peter.alexander.au — 2012-04-15T07:50:50Z
*** Issue 7915 has been marked as a duplicate of this issue. ***
Comment #2 by peter.alexander.au — 2012-04-15T07:54:16Z
Increased to regression because this code works in 2.058.
Workaround: move the definition of foo before the definition of zero. It's a forward reference issue.
Comment #3 by github-bugzilla — 2012-04-16T22:15:51Z