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.
Same thing with immutable.
Maybe a duplicate of issue 13930. https://issues.dlang.org/show_bug.cgi?id=13930
@tom-tan updated dlang/phobos pull request #7655 "Fix `receiveOnly` for non-assignable types (issue 13930, issue 19345)" fixing this issue: - Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types https://github.com/dlang/phobos/pull/7655
dlang/phobos pull request #7655 "Fix issue 13930, 19345 - Fix `receiveOnly` for non-assignable types " was merged into master: - d86c1f605995b423dd1a467b2c1c530dc52adb1e by Tomoya Tanjo: Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types https://github.com/dlang/phobos/pull/7655
dlang/phobos pull request #7657 "Revert "Fix issue 13930, 19345 - Fix `receiveOnly` for non-assignable types "" was merged into master: - 756242350896019ffc7a7cbe05e838538a559f5a by Mathias LANG: Revert "Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types" This reverts commit 4f4fef19400ff85eb4699d569b02b21299b254cc. https://github.com/dlang/phobos/pull/7657
@tom-tan created dlang/phobos pull request #7661 "Fix issue 13930, 19345 - Fix `receiveOnly` for non-assignable types" fixing this issue: - Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types https://github.com/dlang/phobos/pull/7661
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9765 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB