how is this array subtyping inside struct (bug?) possible?
alexandru.ermicioi at gmail.com
Tue Aug 11 22:11:51 UTC 2020
On Monday, 10 August 2020 at 20:42:34 UTC, Steven Schveighoffer
> On 8/10/20 4:13 PM, mw wrote:
>>>> This defeats the purpose, i.e. the convenience that
>>>> subtyping mechanism supposed to provide.
>>> You are subtyping but inadvertently have turned a forward
>>> range (array) into an input range (iterate only once) by
>>> changing it into a class.
>> This subtyping loophole should be fixed by the compiler.
> No, it is doing exactly what you asked it to do -- turn a
> non-reference type into a full reference type.
> The fault here is Phobos for accepting classes as ranges (range
> classes are IMO an abomination that should never be used).
Yet, they allow to mask implementation of a range. Phobos
shouldn't just prohibit all class based ranges, just those that
don't implement right interfaces, such as InputRange(T) or
More information about the Digitalmars-d