Skip to content

Commit

Permalink
fix Issue 14806 - alias this doesn't force elaborate equality, but is…
Browse files Browse the repository at this point in the history
… followed during it
  • Loading branch information
9rnsr committed Jul 19, 2015
1 parent 84294e1 commit 83fa6ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/clone.c
Expand Up @@ -368,6 +368,8 @@ bool needOpEquals(StructDeclaration *sd)
TypeStruct *ts = (TypeStruct *)tv;
if (needOpEquals(ts->sym))
goto Lneed;
if (ts->sym->aliasthis) // Bugzilla 14806
goto Lneed;
}
}
Ldontneed:
Expand Down
34 changes: 33 additions & 1 deletion test/runnable/aliasthis.d
Expand Up @@ -1674,7 +1674,10 @@ struct RefCounted12008(T)
return 0;
}

int refCountedPayload() inout;
int refCountedPayload() inout
{
return 0;
}

alias refCountedPayload this;
}
Expand Down Expand Up @@ -1802,6 +1805,34 @@ void test13009()
alias ISput = IS .put;
}

/***************************************************/
// 14806

struct Nullable14806
{
float get() { return float.nan; }
alias get this;
}

struct Foo14806(T)
{
T bar;
Nullable14806 baz;
}

void test14806()
{
Foo14806!int a, b;
assert(a != b);
// ==> a.tupleof != b.tupleof
// ==> a.bar != b.bar || a.baz.get() != b.baz.get()

Foo14806!string c, d;
assert(c != d);
// ==> c.tupleof != d.tupleof
// ==> c.bar != d.bar || c.baz.get() != d.baz.get()
}

/***************************************************/

int main()
Expand Down Expand Up @@ -1857,6 +1888,7 @@ int main()
test11800();
test13490();
test11355();
test14806();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 83fa6ac

Please sign in to comment.