Fields with the same name not causing a warning?

Dennis dkorpel at gmail.com
Fri Nov 16 22:24:09 UTC 2018


On Friday, 16 November 2018 at 20:13:42 UTC, Vinay Sajip wrote:
> More complicated for the compiler writers, or users of 
> mixins/generics?

For users of generics. It's hard to come up with an actual 
example because I don't know why one would ever use this, but in 
this concocted scenario:

```
mixin template initRange() {
   typeof(this) front = typeof(this).init;
   enum empty = true;
   void popFront() {}
}

class A {
   mixin initRange;
}

class B : A {
   mixin initRange;
}
```

The initRange template would need a static if to decide whether 
to add `override` or not.

On Friday, 16 November 2018 at 20:13:42 UTC, Vinay Sajip wrote:
> But presumably making it an error would potentially be a 
> breaking change?

It would be breaking. The question is how much breakage there is 
of 'correct' hiding vs. how often unintended hiding leads to 
problems.



More information about the Digitalmars-d-learn mailing list