Bug 7641 – std.typecons.Proxy incorrectly allows implicit conversion to class
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-03T22:11:00Z
Last change time
2015-06-09T05:10:39Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2012-03-03T22:11:32Z
import std.typecons;
void main()
{
class C {}
auto a = Typedef!C(new C);
C b = a; // accepts-invalid
}
This is a dmd bug, because opBinaryRight runs unexpectedly.
Reduced test case:
mixin template Proxy(alias a)
{
auto ref opBinaryRight(string op, B)(auto ref B b)
{
return mixin("b "~op~" a");
}
}
struct Typedef(T)
{
private T Typedef_payload;
this(T init)
{
Typedef_payload = init;
}
mixin Proxy!Typedef_payload;
}
void main()
{
class C {}
C c1 = new C();
auto a = Typedef!C(c1);
C c2 = a;
}