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

          Issue ID: 16412
           Summary: instance variable shadowing with inheritance
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Classes should not be allowed to shadow non-private instance variables from
their base:

class Parent
{
    int x = 1;
}
class Child: Parent
{
    int x = 3;
}
void main()
{
    Child child = new Child();
    Parent parent = child;

    assert(parent is child);       // same object
    assert(parent.x != child.x);   // different value for member x
}

--

Reply via email to