12.08.2021 14:32, Paul Backus пишет:

This is not true. Qualifying the ctor as `inout` works fine: https://run.dlang.io/is/Kpzp5M

The problem in this example is that `.dup` always returns a mutable array, even if the array being copied is `inout`. The solution is to cast the copy back to the original type:

```d
this(ref return scope inout A rhs) inout
{
     data = cast(typeof(rhs.data)) rhs.data.dup;
}
```

Yes, it's not true. I forgot that ctors are special in contrast to regular methods and can modify the aggregate they belong to even if the ctor has const/immutable/inout qualifier.

Reply via email to