diff --git a/src/core/thread/osthread.d b/src/core/thread/osthread.d index 2915225865..2e76335277 100644 --- a/src/core/thread/osthread.d +++ b/src/core/thread/osthread.d @@ -256,7 +256,7 @@ class Thread : ThreadBase * In: * fn must not be null. */ - this( void function() fn, size_t sz = 0 ) @safe pure nothrow @nogc + this(return scope void function() fn, size_t sz = 0) @safe pure nothrow @nogc { super(fn, sz); } @@ -273,7 +273,7 @@ class Thread : ThreadBase * In: * dg must not be null. */ - this( void delegate() dg, size_t sz = 0 ) @safe pure nothrow @nogc + this(return scope void delegate() dg, size_t sz = 0) @safe pure nothrow @nogc { super(dg, sz); } @@ -1143,6 +1143,18 @@ unittest thr.join(); } +// https://issues.dlang.org/show_bug.cgi?id=22124 +unittest +{ + Thread thread = new Thread({}); + auto fun(Thread t, int x) + { + t.__ctor({x = 3;}); + return t; + } + assert(!__traits(compiles, () @nogc => fun(thread, 3) )); +} + unittest { import core.sync.semaphore; diff --git a/src/core/thread/threadbase.d b/src/core/thread/threadbase.d index c2c2333efe..b70908b95b 100644 --- a/src/core/thread/threadbase.d +++ b/src/core/thread/threadbase.d @@ -100,14 +100,14 @@ class ThreadBase // Initialization /////////////////////////////////////////////////////////////////////////// - this(void function() fn, size_t sz = 0) @safe pure nothrow @nogc + this(return scope void function() fn, size_t sz = 0) @safe pure nothrow @nogc in(fn) { this(sz); m_call = fn; } - this(void delegate() dg, size_t sz = 0) @safe pure nothrow @nogc + this(return scope void delegate() dg, size_t sz = 0) @safe pure nothrow @nogc in(dg) { this(sz);