Bug 3535 – struct constructors don't work in CTFE

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-11-20T15:49:00Z
Last change time
2015-06-09T01:27:02Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
wbaxter
Blocks
4888

Comments

Comment #0 by wbaxter — 2009-11-20T15:49:09Z
struct Struct { this(int _n) { n = _n; x = 5; } this(int _n, float _x) { n = _n; x = _x; } int n; float x; } enum A = Struct(1); enum A = Struct(1,2); Both calls fail. But if you /don't/ define any constructors then the second one would work.
Comment #1 by wbaxter — 2009-11-20T15:50:40Z
Additional note: static opCall does work with CTFE.
Comment #2 by clugdbug — 2010-01-10T11:44:54Z
I have sent Walter a patch for this. This was much more difficult than you might expect.
Comment #3 by bugzilla — 2010-01-11T22:02:24Z
Changeset 332
Comment #4 by bugzilla — 2010-01-30T22:44:57Z
fixed dmd 2.040