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 }
This is correct code according to the spec: https://dlang.org/spec/class.html#fields This is not shadowing. Each class gets its own set and they don't conflict.