Test case: class C {} thisTid.send(new immutable(C)()); receive((immutable C) { writeln("got it!"); }); This throws: core.exception.AssertError@/usr/include/d/dmd/phobos/std/variant.d(285): immutable(C) And when I replace immutable(C) with Rebindable, I get "Aliases to mutable thread-local data not allowed.".
https://github.com/D-Programming-Language/phobos/commit/325a8fe64a15c57dcde3f8326ad35cfd638f86c7 Fixed the Rebindable part. Hopefully the Variant part will be fixed with Rob Jacques's upcoming Variant update.
Ping. This is a really important issue for multithreaded D. Seems like after 2 years this should be able to be patched.
Looks like this works on DMD head. Updated sample (added name for parameter to allow compiling and wrapped in main): import std.variant, std.concurrency; class C {} void main() { thisTid.send(new immutable(C)()); receive((immutable C c) { writeln("got it!"); }); } DMD 2.065.0: rdmd test.d core.exception.AssertError@/opt/dmd/phobos/std/variant.d(288): immutable(C) DMD Git Head: rdmd test.d got it!