Re: Immutable array initialization in shared static this

2012-07-16 Thread Tommi
Hmm.. actually, it seems there have been plenty of reports of this issue already. Didn't see it the first time: http://d.puremagic.com/issues/show_bug.cgi?id=6174

Re: Immutable array initialization in shared static this

2012-07-14 Thread Tommi
On Friday, 13 July 2012 at 18:09:59 UTC, Era Scarecrow wrote: I would think the best solution is to create a mutable local version, and then assign the immutable global one when you are done. Thanks for the workaround. But I'm actually more interested in whether or not this is a compiler

Immutable array initialization in shared static this

2012-07-13 Thread Tommi
The following code doesn't compile. It seems like a compiler bug to me, but I can't find a bug report about it. Is it a bug? private immutable(int[]) constants; shared static this() { constants.length = 10; constants[0] = 123; // Error: constants[0] isn't mutable }

Re: Immutable array initialization in shared static this

2012-07-13 Thread Jonathan M Davis
On Friday, July 13, 2012 12:15:33 Tommi wrote: The following code doesn't compile. It seems like a compiler bug to me, but I can't find a bug report about it. Is it a bug? private immutable(int[]) constants; shared static this() { constants.length = 10; constants[0] = 123; //

Re: Immutable array initialization in shared static this

2012-07-13 Thread Minas Mina
I guess it's because you have an array of constants (immutables). The array is not immutable though. I could be wrong, I'm not an expert or D syntax :)

Re: Immutable array initialization in shared static this

2012-07-13 Thread Era Scarecrow
When you use the length property it allocates space and assigns it to the immutable array. the array now contains data (10 0's). You've said you won't change any data in it's declaration but the array itself can be changed (appending or a different array). I would think the best solution is

Re: Immutable array initialization in shared static this

2012-07-13 Thread Ali Çehreli
On 07/13/2012 11:09 AM, Era Scarecrow wrote: I would think the best solution is to create a mutable local version, and then assign the immutable global one when you are done. And there wouldn't be a copy with std.exception.assumeUnique: import std.exception; private immutable(int[])