digitalmars.D.learn - static init of associative array of enums not working.. why?
- =?UTF-8?B?w5hpdmluZA==?= (24/24) Feb 26 2016 Shouldn't this work? According to "Static Initialization of AAs"
- Adam D. Ruppe (16/19) Feb 26 2016 It just isn't implemented in the compiler. Instead, you can
- =?UTF-8?B?w5hpdmluZA==?= (4/6) Feb 26 2016 That was quick! Thank you.
- Adam D. Ruppe (3/4) Feb 26 2016 It is already known, just nobody has fixed it yet (and probably
Shouldn't this work? According to "Static Initialization of AAs" on this page, it should: https://dlang.org/spec/hash-map.html enum DevicePropDataType { dString, dDateTime } enum DevicePropValType { property, miscDate } immutable DevicePropDataType[DevicePropValType] propDType = [ DevicePropValType.property: DevicePropDataType.dString, DevicePropValType.miscDate: DevicePropDataType.dDateTime ]; void main() { } I get the following error: /d847/f751.d(12): Error: non-constant expression [cast(DevicePropValType)0:cast(DevicePropDataType)0, cast(DevicePropValType)1:cast(DevicePropDataType)1]
Feb 26 2016
On Saturday, 27 February 2016 at 04:15:06 UTC, Øivind wrote:Shouldn't this work? According to "Static Initialization of AAs" on this page, it should: https://dlang.org/spec/hash-map.htmlIt just isn't implemented in the compiler. Instead, you can declare it outside and set it in a static module constructor: immutable DevicePropDataType[DevicePropValType] propDType; shared static this() { propDType = [ DevicePropValType.property: DevicePropDataType.dString, DevicePropValType.miscDate: DevicePropDataType.dDateTime ]; } void main() { }
Feb 26 2016
On Saturday, 27 February 2016 at 04:35:41 UTC, Adam D. Ruppe wrote:It just isn't implemented in the compiler. Instead, you can declare it outside and set it in a static module constructor:That was quick! Thank you. Should I file a ticket for this?
Feb 26 2016
On Saturday, 27 February 2016 at 04:37:24 UTC, Øivind wrote:Should I file a ticket for this?It is already known, just nobody has fixed it yet (and probably won't for a long time still)
Feb 26 2016