digitalmars.D.bugs - [Issue 1792] New: illegal opAssign possible via alias
- d-bugmail puremagic.com (22/22) Jan 19 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1792
- d-bugmail puremagic.com (25/25) Sep 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1792
http://d.puremagic.com/issues/show_bug.cgi?id=1792 Summary: illegal opAssign possible via alias Product: D Version: 1.025 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: benoit tionex.de From http://digitalmars.com/d/1.0/operatoroverloading.html The assignment operator cannot be overloaded for rvalues that can be implicitly cast to the lvalue type. Doing so results in a compiler error. But doing it via an alias, the compiler does not complain. class C{ C set( C c ){ return c; } alias set opAssign; } --
Jan 19 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1792 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com The compiler accepts the code, but the assignment operator doesn't actually overload: ---------- import std.stdio; class C { C set(C c) { writefln("Calling C.set"); return c; } alias set opAssign; } void main() { C d = new C; C e = new C; d = e; } ---------- generates no output on run. --
Sep 09 2008