Bug 514 – Misleading error message for static const initialisation

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P5
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-15T06:15:00Z
Last change time
2014-02-15T13:20:14Z
Keywords
diagnostic
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2006-11-15T06:15:12Z
class C { static const int x; this() { x = 2; } } The above code errors out with "Error: can only initialize const x inside constructor". This is rather unclear, as x _is_ being initialised inside a constructor. The compiler should notify that the variable is static and thus needs to be initialised in a static constructor.
Comment #1 by matti.niemenmaa+dbugzilla — 2006-12-03T03:42:33Z
Fixed in DMD 0.176.