Bug 14806 – [REG2.063] alias this doesn't force elaborate equality, but is followed during it
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-17T18:10:00Z
Last change time
2015-07-24T03:20:22Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
ag0aep6g
Comments
Comment #0 by ag0aep6g — 2015-07-17T18:10:37Z
Found by TC, who posted to D.learn:
http://forum.dlang.org/post/[email protected]
Either both asserts should pass, or they should both fail.
With dmd 2.062 and older both asserts pass.
----
struct Nullable
{
float get() {return float.nan;}
alias get this;
}
struct Foo(T)
{
T bar;
Nullable baz;
}
void main()
{
Foo!int a, b;
assert(a == b); /* passes, as Nullable.init == Nullable.init */
Foo!string c, d;
assert(c == d); /* fails, as float.init != float.init */
}
----
Comment #1 by k.hara.pg — 2015-07-19T03:48:36Z
(In reply to ag0aep6g from comment #0)
> Either both asserts should pass, or they should both fail.
Both asserts should fail, because they should be translated as follows:
Foo!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()
Compiler fix (targetting 2.068 release):
https://github.com/D-Programming-Language/dmd/pull/4820
Comment #2 by github-bugzilla — 2015-07-19T05:11:18Z