[Issue 7641] New: std.typecons.Proxy incorrectly allows implicit conversion to class
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 3 22:11:33 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7641
Summary: std.typecons.Proxy incorrectly allows implicit
conversion to class
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-03-03 22:11:32 PST ---
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;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list