Can't assign to static array in ctor?

Daniel Murphy yebblies at nospamgmail.com
Mon Apr 9 19:11:54 PDT 2012


"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
news:mailman.1550.1333997204.4860.digitalmars-d at puremagic.com...
> What's the reason the following code doesn't compile?
>
> struct S {
> const(int)[4] data;
> this(const(int)[4] d) {
> data = d; // this is line 4
> }
> }
>
> void main() {
> S s;
> }
>
> Compiler error:
>
> test.d(4): Error: slice this.data[] is not mutable
>
> Shouldn't the assignment be valid in the ctor?
>
>
> T

Static array assignments are converted to slice assignments waaay too early. 




More information about the Digitalmars-d mailing list