On 1/8/21 3:10 PM, tsbockman wrote:

> On Friday, 8 January 2021 at 20:43:37 UTC, Andrey wrote:
>> Hello,
>>
>>> struct Value
>>> {
>>>     int value;
>>>     string data;
>>>     string[] text;

The destination is immutable(char)[]. The characters cannot be changed. We can still append but other slices that share the same data is protected by D's no-stomp decision.

>>> }
>>>
>>> void test(const ref Value value)
>>> {
>>>     Value other = void;
>>>     other.text = value.text;

Even though the source is 'const ref', other.text is a copy of the slice object (the pointer and the length). Because the elements are immutable, other.text cannot mutate value.text.

>>> }
>>>
>>> void main()
>>> {
>>>     Value row;
>>>     row.value = 10;
>>>     row.data = "ttttggg";
>>>
>>>     test(row);
>>> }

> Your code has a logical inconsistency

I don't see where. I think this is one of those too strict cases of D where I unhappily slap a cast and move on.

Ali

Reply via email to