www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12791] New: .tupleof does not take base class fields into

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

          Issue ID: 12791
           Summary: .tupleof does not take base class fields into account
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
class A
{
    int a;
}

class B : A
{
    int b;

    B clone()
    {
        auto b = new B;
        b.tupleof = this.tupleof;
        return b;
    }
}

void main()
{
    auto b = new B;
    b.a = 10;
    b.b = 20;

    auto clone = b.clone();
    assert(clone.b == 20);
    assert(clone.a == 10);  // fails, it's 0
}
-----

Since working with .tupleof is a fairly new and experimental feature I think
the above could be labeled an enhancement request.

--
May 23 2014