Immutable static arrays

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 16 21:43:44 PDT 2012


On Sat, Mar 17, 2012 at 03:03:02PM +1100, Daniel Murphy wrote:
> "H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
> news:mailman.804.1331956668.4860.digitalmars-d at puremagic.com...
[...]
> > P.S. The error message is:
> >
> > newAA.d(58): Error: slice this.key[] is not mutable
[...]
> > Why is the assignment being translated into a slice for the
> > assignment?
[...]
> 
> Oh, this.  There are a bunch of bugs with const/immutable static
> arrays.  During AssignExp::semantic, a = b (where a and b are static
> arrays) gets converted to a[] = b[].  This is incorrect, the
> transformation should happen during the glue layer. 
[...]

Argh. So I have to hack around this by casting an immutable static array
key into a mutable one inside the AA? (Which should work, I suppose,
because a copy is being made.) Or should I just leave this alone for now
and wait for dmd to be fixed?


T

-- 
Being able to learn is a great learning; being able to unlearn is a greater learning.


More information about the Digitalmars-d mailing list