[Issue 20795] [dip1000] segfault on templated opEquals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 3 23:17:53 UTC 2020


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

--- Comment #2 from moonlightsentinel at disroot.org ---
(In reply to moonlightsentinel from comment #1)
Tuple isn't required:

struct Foo
{
    void opEquals(T)(T rhs) if (T.init.opCast!string) {}
}

struct Bar
{
    void opEquals()(Bar)
    {
        Gun() == Foo.init;
    }
}

class Baz
{
    void opCast(T)() {}
}

struct Gun
{
    void[24] buff;

    auto underlying()
    {
        return cast(Baz) buff.ptr;
    }

    alias underlying this;

    void opEquals(R)(R) if (mixin("Bar.init == R.init")) {}
}

--


More information about the Digitalmars-d-bugs mailing list