auto return type inheritance not covariant

iLewis ilewis_isradd at hotmail.com
Wed Feb 2 15:31:02 PST 2011


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;
	}
}



More information about the Digitalmars-d-bugs mailing list