[Issue 14806] New: alias this doesn't force elaborate equality, but is followed during it

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 17 11:10:37 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14806

          Issue ID: 14806
           Summary: alias this doesn't force elaborate equality, but is
                    followed during it
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com

Found by TC, who posted to D.learn:
http://forum.dlang.org/post/ohkyebycxuszarhtbysm@forum.dlang.org

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 */
}
----

--


More information about the Digitalmars-d-bugs mailing list