Immutability and arrays
    rumbu 
    rumbu at rumbu.ro
       
    Wed Dec 15 06:10:59 UTC 2021
    
    
  
On Tuesday, 14 December 2021 at 16:21:03 UTC, Steven 
Schveighoffer wrote:
> On 12/14/21 11:19 AM, Steven Schveighoffer wrote:
>
>> Er... scratch that, this isn't construction, it should use 
>> opAssign. Again, probably because memcpy+postblit is used by 
>> the runtime.
>> 
>> If not reported, it should be.
>
> Simple proof that it is a bug:
>
> ```d
> immutable (ComplexStruct)[] arr;
> ComplexStruct[] arr2;
>
> arr2[0] = arr[0]; // ok
> arr2[] = arr[]; // error
> ```
>
> If you can copy one element, you should be able to copy all the 
> elements.
>
> -Steve
Thank you everybody, especially to Steve for the detailed 
explanation.
It seems that every post I put in the learn forum, results in a 
bug report :)
https://issues.dlang.org/show_bug.cgi?id=22601
https://issues.dlang.org/show_bug.cgi?id=22600
    
    
More information about the Digitalmars-d-learn
mailing list