Associative array bug?

Max Samuha maxter at i.com.ua_spamless
Fri Jun 16 00:58:08 PDT 2006


Can interfaces be used as AA keys? The following code causes access
violation (WinXP, dmd 0.160):

interface I
{
	void method();
}

class A : I
{
	void method()
	{
	}
}

void main()
{
	I a = new A();
	
	int[I] array;

	array[a] = 5; // Access violation	
}

When I replace the interface with a base class, it works.

abstract class I
{
	void method();
}

class A : I
{
	override void method()
	{
	}
}

void main()
{
	I a = new A();
	
	int[I] array;

	array[a] = 5; // Ok	
}

Is it a known bug?



More information about the Digitalmars-d-learn mailing list