static init of associative array of enums not working.. why?

Øivind via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 26 20:15:06 PST 2016


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]


More information about the Digitalmars-d-learn mailing list