www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15354] New: unstable operator overloading with mixin expression

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 puremagic.com
          Reporter: k.hara.pg 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 ?
}

--
Nov 18 2015