[Issue 15354] New: unstable operator overloading with mixin expression

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Nov 18 05:01:14 PST 2015


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

          Issue ID: 15354
           Summary: unstable operator overloading with mixin expression
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

Test case:

struct S
{
    int x;
    int y;

    void opIndexAssign(int v, int n)
    {
        x = v;
    }

    ref int opIndex(int n)
    {
        return y;
    }
}

void main()
{
    S s1;
    s1[0] = 1;
    assert(s1.x == 1);

    S s2;
    mixin("s2[0]") = 1;
    assert(s2.y == 1);  // shouldn't be s2.x == 1 ?
}

--


More information about the Digitalmars-d-bugs mailing list