Bug 1209 – static class constructor not called

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-05-01T16:06:00Z
Last change time
2014-02-16T15:25:55Z
Assigned to
bugzilla
Creator
leo.dahlmann

Comments

Comment #0 by leo.dahlmann — 2007-05-01T16:06:15Z
In the following code the static constructor of Foo is not called and thus the assert in main fails. If you replace this() with static this() it works. I think, because this() is inside a static block, it should be static. ################################################################# uint x = 0; class Foo { static { this() { x++; } } } void main() { assert(x == 1); }
Comment #1 by thomas-dloop — 2007-05-20T13:11:37Z
http://www.digitalmars.com/d/class.html : # # The static in the static constructor declaration is not an # attribute, it must appear immediately before the this #