Thread overview
Error: TypeInfo.equals is not implemented
Feb 08, 2014
Andre
Feb 08, 2014
Stanislav Blinov
Feb 08, 2014
bearophile
Feb 08, 2014
Stanislav Blinov
Feb 08, 2014
bearophile
Feb 08, 2014
Stanislav Blinov
Feb 08, 2014
Stanislav Blinov
Feb 08, 2014
Andre
February 08, 2014
Hi,

I do not understand the following error message. I have template structure Decimal, which is used in a OrderDb structure.

Comparing two OrderDb structures is working, but trying to compare
two OrderDb array structures ends with an error message:
object.Error: TypeInfo.equals is not implemented.

Kind regards
André

--- Code ---

import std.traits: isInstanceOf;

struct Decimal(int precision, int scale){
	bool opEquals(T)(T d)
		if (isInstanceOf!(Decimal, T))
	{
		return false;
	}
}

struct OrderDb{
	string orderId;
	Decimal!(10,2) amount;
}

void main(){
	auto o1 = OrderDb();
	auto o2 = OrderDb();
	if (o1 == o2) {}; // Works
	if ([o1] == [o2]) {}; // object.Error: TypeInfo.equals is not implemented
}
February 08, 2014
opEquals should be const:

struct Decimal(int precision, int scale){
	bool opEquals(T)(T d) const
		if (isInstanceOf!(Decimal, T))
	{
		return false;
	}
}
February 08, 2014
Stanislav Blinov:

> opEquals should be const:
>
> struct Decimal(int precision, int scale){
> 	bool opEquals(T)(T d) const
> 		if (isInstanceOf!(Decimal, T))
> 	{
> 		return false;
> 	}
> }

DMD needs to give better error messages in such cases.

Bye,
bearophile
February 08, 2014
On Saturday, 8 February 2014 at 14:15:56 UTC, bearophile wrote:

> DMD needs to give better error messages in such cases.

Naturally. Especially since that was a runtime exception %\


February 08, 2014
Stanislav Blinov:

> Naturally. Especially since that was a runtime exception %\

Is this already in a bugzilla entry?

Bye,
bearophile
February 08, 2014
On Saturday, 8 February 2014 at 15:51:11 UTC, bearophile wrote:

> Is this already in a bugzilla entry?

Can't find anything similar. I'll reduce and post it.
February 08, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12108
February 08, 2014
Am 08.02.2014 17:14, schrieb Stanislav Blinov:
> https://d.puremagic.com/issues/show_bug.cgi?id=12108

Thanks a lot.

Kind regards
André