[Issue 15355] New: unstable operator overloading with comma expression

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


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

          Issue ID: 15355
           Summary: unstable operator overloading with comma 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;
    (1, s2[0]) = 1;
    assert(s2.y == 1);  // shouldn't be s2.x == 1 ?
}

--


More information about the Digitalmars-d-bugs mailing list