Comment #0 by pro.mathias.lang — 2018-10-31T02:40:09Z
The following code:
```
@system unittest
{
static struct Aggregate { const int a; const int[5] b; }
static void t1(Tid mainTid)
{
const sendMe = Aggregate(42, [1, 2, 3, 4, 5]);
mainTid.send(sendMe);
mainTid.send(0, sendMe);
}
auto tid = spawn(&t1, thisTid);
tid.send(1);
auto result = receiveOnly!Aggregate();
immutable expected = Aggregate(42, [1, 2, 3, 4, 5]);
assert(result == expected);
}
```
Will fail to compile and yield the following error message:
```
std/concurrency.d(777): Error: cannot modify struct instance ret.__expand_field_0 of type Aggregate because it contains const or immutable members
```
This is because `std.concurrency` creates a struct, then assign its fields here: https://github.com/dlang/phobos/blob/9fcf1f1b77a3a10f5369466cce58e8af7dc8ebcf/std/concurrency.d#L773-L777
In some cases, it's possible to use `receive` as a workaround, which offers a delegate interface.