October 13, 2005
Using DMD 0.131 (has DMD itself actually changed since then?), Windows 98SE.

----------
enum Qwert { yuiop }

void asdfg(Qwert hjkl) { printf("Called hjkl(Qwert)\n"); }
void asdfg(uint zxcvb) { printf("Called hjkl(uint)\n"); }

void main() {
    int nm = 2;

    asdfg(nm);
    asdfg(cast(int) nm);
    asdfg(3);
    asdfg(cast(int) 3);
}
----------
D:\My Documents\Programming\D\Tests\implicit_enum.d(11): function implicit_enum.asdfg called with argument types:
    (int)
matches both:
    implicit_enum.asdfg(Qwert )
and:
    implicit_enum.asdfg(uint)
D:\My Documents\Programming\D\Tests\implicit_enum.d(12): function implicit_enum.asdfg called with argument types:
    (int)
matches both:
    implicit_enum.asdfg(Qwert )
and:
    implicit_enum.asdfg(uint)

Tool completed with exit code 1
----------

For the integer variable, it manages to resolve the overload.  Indeed, it calls the uint version.

However, with the literal, it doesn't, even if it has been cast.  This is absurd.  Just as integer variables don't implicitly convert to enums, neither should integer literals.  And that line 10 passes but line 12 doesn't is even more absurd, as both have the same type set in the same amount of stone.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
May 21, 2006
Stewart Gordon schrieb am 2005-10-13:
> Using DMD 0.131 (has DMD itself actually changed since then?), Windows 98SE.
>
> ----------
> enum Qwert { yuiop }
>
> void asdfg(Qwert hjkl) { printf("Called hjkl(Qwert)\n"); }
> void asdfg(uint zxcvb) { printf("Called hjkl(uint)\n"); }
>
> void main() {
>      int nm = 2;
>
>      asdfg(nm);
>      asdfg(cast(int) nm);
>      asdfg(3);
>      asdfg(cast(int) 3);
> }
> ----------
> D:\My Documents\Programming\D\Tests\implicit_enum.d(11): function
> implicit_enum.asdfg called with argument types:
>      (int)
> matches both:
>      implicit_enum.asdfg(Qwert )
> and:
>      implicit_enum.asdfg(uint)
> D:\My Documents\Programming\D\Tests\implicit_enum.d(12): function
> implicit_enum.asdfg called with argument types:
>      (int)
> matches both:
>      implicit_enum.asdfg(Qwert )
> and:
>      implicit_enum.asdfg(uint)
>
> Tool completed with exit code 1
> ----------
>
> For the integer variable, it manages to resolve the overload.  Indeed, it calls the uint version.
>
> However, with the literal, it doesn't, even if it has been cast.  This is absurd.  Just as integer variables don't implicitly convert to enums, neither should integer literals.  And that line 10 passes but line 12 doesn't is even more absurd, as both have the same type set in the same amount of stone.

Added to DStress as http://dstress.kuehne.cn/run/o/overload_26_A.d http://dstress.kuehne.cn/run/o/overload_26_B.d

Thomas