www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - wrong function overload

reply Karen Lanrap <karen digitaldaemon.com> writes:
import std.stdio;
enum COLOR{RED};
enum TYPE{SOFT_TOP};
class Car{
    int val;
    void roof( COLOR c)
    {
      val= 1;
    }
    void roof(TYPE t, int i)
    {
      val= 2;
    }
}
void main(){
    auto mycar= new Car;
    mycar.roof( TYPE.SOFT_TOP); // should not compile
    writefln( mycar.val); // should print 2
}
Sep 27 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karen Lanrap schrieb am 2006-09-27:
 import std.stdio;
 enum COLOR{RED};
 enum TYPE{SOFT_TOP};
 class Car{
     int val;
     void roof( COLOR c)
     {
       val= 1;
     }
     void roof(TYPE t, int i)
     {
       val= 2;
     }
 }
 void main(){
     auto mycar= new Car;
     mycar.roof( TYPE.SOFT_TOP); // should not compile
     writefln( mycar.val); // should print 2
 }
Added to DStress as http://dstres.kuehne.cn/nocompile/e/enum_50_A.d http://dstres.kuehne.cn/nocompile/e/enum_50_B.d http://dstres.kuehne.cn/nocompile/e/enum_50_C.d http://dstres.kuehne.cn/nocompile/e/enum_50_D.d http://dstres.kuehne.cn/nocompile/e/enum_50_E.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFHMrsLK5blCcjpWoRAmTnAJ4hndbSLVzzv6QhD1UU8Yfvtx9eAwCfewI0 4P79FCUiddUz8QLhQGMN4Ao= =cw8D -----END PGP SIGNATURE-----
Sep 29 2006