how is this array subtyping inside struct (bug?) possible?
mw
mingwu at gmail.com
Mon Aug 10 19:49:03 UTC 2020
On Monday, 10 August 2020 at 19:30:18 UTC, Steven Schveighoffer
wrote:
> This is precisely why classes should never be ranges.
And the user didn't code this range, the range is provided by the
language standard library:
https://dlang.org/phobos/std_range_primitives.html
it's the std library that didn't take into account of the
array-be-subtyped-as class loop-hole.
Ideally, to the user, subtyping should just perform simple
forward to the underlying data member, i.e.
writeln(s0.fns);
should be translated by the *compiler* to:
writeln(s0.fns.array);
Obviously it failed to do so here.
More information about the Digitalmars-d
mailing list