digitalmars.D.bugs - Bug in operator overloading!
- Ivan Senji (25/25) Aug 07 2004 class A{}
- Ben Hinkle (5/7) Aug 07 2004 These two should error but do pointer arithmetic instead. That seems lik...
class A{} void main () { A a,b; a=new A; b=new A; writefln(a==b); writefln(a<b); writefln(a+b); writefln(a-b); writefln(a*b); //'a' is not an arithmetic type } WHY? Why don't the first four writefln's couse error messages from compiler! I see it as a huge problem for generic programming! For example: this template will work for the above A class an any other class you write, even if you don't provide an opAdd operator! template func(Type) { Type func(Type a, Type b) { return a+b; } }
Aug 07 2004
writefln(a+b); writefln(a-b);These two should error but do pointer arithmetic instead. That seems like a bug. The a==b and a<b are working as designed but by your post on the main newsgroup I think you'd like to see the design changed - which is different than the a+b and a-b examples.
Aug 07 2004