www.digitalmars.com         C & C++   DMDScript  

D - up cast in foreach?

will it be valid?
for 1.0?


class A
{
}

class B : A
{
}

int main(char[][] args)
{

	B b;

	A a = b;
	
	B[] bs;
	
	a = bs[123];	// valid 
	
	foreach(A a ; bs)	// invalid
	{
	}
	
	return 0;
}


dmd ../C.d -I~/dmd/src/phobos
../C.d(20): foreach: B [] is not an array of A


if A is an interface the compiler produces the same message.

Ant
Apr 13 2004