Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
February 08, 2014 Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
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 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre | 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 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | 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 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | Stanislav Blinov:
> Naturally. Especially since that was a runtime exception %\
Is this already in a bugzilla entry?
Bye,
bearophile
|
February 08, 2014 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | https://d.puremagic.com/issues/show_bug.cgi?id=12108 |
February 08, 2014 Re: Error: TypeInfo.equals is not implemented | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | 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é
|
Copyright © 1999-2021 by the D Language Foundation