[Issue 2095] covariance w/o typechecks = bugs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 17 15:29:06 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=2095


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #17 from Jonathan M Davis <jmdavisProg at gmx.com> 2010-11-17 15:27:51 PST ---
It really should be stopped at compile time. There's not really a good reason
to allow it. As much as it first looks like mixing A[] and B[] when B : A
should work, it's a _really_ bad idea. Just because a container holds a type
which is the base type of another type does not mean that a container which
holds the derived type should be assignable/castable/convertable to one which
holds the base type.

Really, the only question is whether you can get away with it with some form of
const, and I believe that the consensus on it in the newsgroup last time that
this was discussed was that you couldn't. I'd have to go digging through the
archives though to find the exact thread.

This can and should be disallowed at compile time. It's a definite bug. It just
hasn't been fixed yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list