[Issue 2943] Struct copying in presence of alias member this only copies alias this member
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 6 14:40:23 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2943
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
CC| |clugdbug at yahoo.com.au
--- Comment #6 from Don <clugdbug at yahoo.com.au> 2010-10-06 14:39:59 PDT ---
Very simple. This is a special case where alias this should be ignored.
PATCH: opover.c, BinExp::op_overload(), line 684 and 698. Also fixes bug 4641.
#if DMDV2
// Try alias this on first operand
- if (ad1 && ad1->aliasthis)
+ if (ad1 && ad1->aliasthis && !(op == TOKassign && ad2 && ad1 == ad2))
{
/* Rewrite (e1 op e2) as:
* (e1.aliasthis op e2)
*/
// Try alias this on second operand
- if (ad2 && ad2->aliasthis)
+ if (ad2 && ad2->aliasthis && !(op == TOKassign && ad1 && ad1 == ad2))
{
/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
============
TEST FOR TEST SUITE
struct Foo2943 {
int a;
int b;
alias b this;
}
void main() {
Foo2943 foo, foo2;
foo.a = 1;
foo.b = 2;
foo2.a = 3;
foo2.b = 4;
foo2 = foo;
assert(foo2.a == foo.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