http://d.puremagic.com/issues/show_bug.cgi?id=6238
Summary: Cannot define global immutable AA Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: johann.macdon...@gmail.com --- Comment #0 from Johann MacDonagh <johann.macdon...@gmail.com> 2011-07-01 21:54:32 PDT --- I *believe* this bug has been discussed and reported before, but a search didn't turn up anything. This code fails to compile: immutable test = // auto, const, etc.. also fail [ 'a' : 1, 'b' : 2, ]; void main() { } On 2.053 we get: main.d(2): Error: non-constant expression ['a':1,'b':2] A workaround is to do: enum test = [ 'a' : 1, 'b' : 2, ]; void main() { auto localTest = test; // Use either test or localTest } But of course that will cause test to be copied each time it is referenced (which, besides all the drama in issue 4397 I believe to be correct). The reason this matters is because of CTFE. If I have an AA which I want to be able to use in CTFE and at runtime without causing copies to be made at runtime I'd have to use an immutable AA. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------