auto return type inheritance not covariant
Jonathan M Davis
jmdavisProg at gmx.com
Wed Feb 2 15:46:37 PST 2011
On Wednesday, February 02, 2011 15:31:02 iLewis wrote:
> Maybe this has been brought up before, but i could find no previous
> submissions.
>
> the following code compiles with the error "Error: function xxx.B.fn of
> type () overrides but is not covariant with xxx.A.fn of type ()" even
> though they both return an auto of type int... is this a bug or oversight
> by myself? I am unable to find any documentation saying that this is
> illegal.
>
> I realize its easy to fix by changing the return type to int, however i was
> just curious.
>
> class A
> {
> auto fn()
> {
> return 10;
> }
> }
>
> class B : A
> {
> auto fn()
> {
> return 5;
> }
> }
I'm not aware of a bug report on the matter. You should create one at
http://d.puremagic.com/issues . Also, this list is not really intended to be
posted to. It's for seeing the messages about changes to bug reports which the
tracker sends. If you want to post questions, they should generally go to
D.Learn or D.
- Jonathan M Davis
More information about the Digitalmars-d-bugs
mailing list