Sockets can't be moved
schveiguy opened this issue · 3 comments
With dmd 2.083.0, I can't move a Socket
using std.algorithm.move
. I think this is a compiler bug, but I'm not sure why this fails.
I can call Socket.move
no problem, but I can't call std.algorithm.move(Socket)
.
I can easily duplicate the problem in a small test case with:
import std.algorithm : move;
struct S
{
int x;
S foo() return nothrow @nogc pure { return S(x); }
this(this) @disable;
}
void main()
{
S s(2);
auto s2 = s.foo; // ok
auto s3 = move(s); // errors
}
Here are the errors (I removed some trivial path info):
std/algorithm/mutation.d(1232): Error: struct `testmove.S` is not copyable because it is annotated with @disable
std/algorithm/mutation.d(1225): Error: template instance `std.algorithm.mutation.moveImpl!(S)` error instantiating
std/algorithm/mutation.d(1183): instantiated from here: trustedMoveImpl!(S)
The really odd thing is that the a member function MUST BE THERE, and it MUST have return
attribute on it.
I will file an equivalent bug in bugzilla with this test case.
Update: it has nothing to do with std.algorithm.move, it's a compiler bug.
Reduced test case:
struct S
{
int x;
S foo() return { return S(x); }
this(this) @disable;
}
auto bar()
{
S s;
return s; // Error: S is not copyable
}
Without the foo member, it works.
Added bugzilla issue: https://issues.dlang.org/show_bug.cgi?id=19415
Should be fixed with the upcoming v2.084.0-beta.1.