[Issue 19774] wrong code caused by generic variadic opIndex

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 5 13:09:04 UTC 2019


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

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
Slighlty more reduced:

----
C bar()
{
    return C(42);
}

C foo()
{
    return bar()[1];
}

struct C
{
    int x;

    ~this()
    {
        x = 0;
    }

    C opIndex(int a)
    {
        return this;
    }
}

void main()
{
    auto c = foo();
    assert(c.x == 42); /* fails; should pass */
}
----

--


More information about the Digitalmars-d-bugs mailing list