[Issue 349] New: Function matching with enums is erratic
Thomas Kuehne
thomas-dloop at kuehne.cn
Wed Sep 20 12:19:21 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail at puremagic.com schrieb am 2006-09-15:
> http://d.puremagic.com/issues/show_bug.cgi?id=349
> Integer types are not implicitly convertible to enum types. However, under
> certain conditions the process of matching functions to calls likes to think
> otherwise.
>
> ----------
> import std.stdio;
>
> enum Qwert { yuiop }
>
> void asdfg(Qwert hjkl) { writefln("Called hjkl(Qwert)"); }
> void asdfg(uint zxcvb) { writefln("Called hjkl(uint)"); }
>
> void main() {
> int nm = 2;
>
> asdfg(nm); // works
> asdfg(cast(int) nm); // works
> asdfg(3); // fails
> asdfg(cast(int) 3); // fails
> asdfg(3L); // fails
> asdfg(cast(int) 3L); // fails
> asdfg(3 + 2); // fails
> asdfg(cast(int) (3 + 2)); // fails
> asdfg(nm + 2); // works
> asdfg(cast(int) (nm + 2)); // works
> asdfg(3 + nm); // works
> asdfg(cast(int) (3 + nm)); // works
> }
<snip>
> All of these arguments, except for 3L, are of type int. You can see for
> yourself that int isn't implicitly convertible to Qwert by adding
>
> Qwert qaz = nm;
<snip>
Added to DStress as
http://dstress.kuehne.cn/compile/e/enum_48_A.d
http://dstress.kuehne.cn/compile/e/enum_48_B.d
http://dstress.kuehne.cn/compile/e/enum_48_C.d
http://dstress.kuehne.cn/compile/e/enum_48_D.d
http://dstress.kuehne.cn/run/e/enum_49_A.d
http://dstress.kuehne.cn/run/e/enum_49_B.d
http://dstress.kuehne.cn/run/e/enum_49_C.d
http://dstress.kuehne.cn/run/e/enum_49_D.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFEZ/6LK5blCcjpWoRAnRDAKCDBe4uz0URAuP5XeEK0T3nf7cHsQCfdPaQ
YU4T6MAdN15zqNbgMon4oZU=
=lN1Q
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list