Bug 7911 – Nested static if failing to execute

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-04-14T08:53:00Z
Last change time
2012-05-25T13:47:02Z
Keywords
rejects-valid
Assigned to
nobody
Creator
marcianx
Blocks
340

Comments

Comment #0 by marcianx — 2012-04-14T08:53:42Z
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
Comment #4 by github-bugzilla — 2012-04-16T22:16:14Z
Comment #5 by github-bugzilla — 2012-05-25T13:47:02Z