digitalmars.D.bugs - Overloading issue with enum in dmd 1.006
- renoX (25/25) Feb 20 2007 Tested in dmd 1.006 on Linux, the two toString definitions conflicts
- Thomas Kuehne (12/30) Feb 27 2007 -----BEGIN PGP SIGNED MESSAGE-----
- renoX (4/43) Mar 03 2007 OK, thanks for your answer, this way I'll avoid opening a bogus fault
Tested in dmd 1.006 on Linux, the two toString definitions conflicts when they are in main, not when they are out of the main function. import std.stdio; int main(char[][] args) { enum Foo { A , B }; enum Foo2 { C , D }; char[] toString(Foo x) { return "1"; } char[] toString(Foo2 x) { return "2"; } Foo s = Foo.A; writefln("s is %s, with name %s\n", s, toString(s)); Foo2 o = Foo2.C; writefln("o is %s, with name %s\n", o, toString(o)); return 0; } regards, renoX
Feb 20 2007
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 renoX schrieb am 2007-02-20:Tested in dmd 1.006 on Linux, the two toString definitions conflicts when they are in main, not when they are out of the main function. import std.stdio; int main(char[][] args) { enum Foo { A , B }; enum Foo2 { C , D }; char[] toString(Foo x) { return "1"; } char[] toString(Foo2 x) { return "2"; }<snip> http://www.digitalmars.com/d/function.htmlUnlike module level declarations, declarations within function scope are processed in order.Thus no overloading for nested functions. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFF5JQELK5blCcjpWoRAuAYAKCe657u4RV2QFzRiGnEle01XRlkAwCfWStE 4vwsRjflR46EqJ1j18VhDwI= =TkIY -----END PGP SIGNATURE-----
Feb 27 2007
Thomas Kuehne a écrit :-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 renoX schrieb am 2007-02-20:OK, thanks for your answer, this way I'll avoid opening a bogus fault report. renoXTested in dmd 1.006 on Linux, the two toString definitions conflicts when they are in main, not when they are out of the main function. import std.stdio; int main(char[][] args) { enum Foo { A , B }; enum Foo2 { C , D }; char[] toString(Foo x) { return "1"; } char[] toString(Foo2 x) { return "2"; }<snip> http://www.digitalmars.com/d/function.htmlUnlike module level declarations, declarations within function scope are processed in order.Thus no overloading for nested functions. Thomas-----BEGIN PGP SIGNATURE----- iD8DBQFF5JQELK5blCcjpWoRAuAYAKCe657u4RV2QFzRiGnEle01XRlkAwCfWStE 4vwsRjflR46EqJ1j18VhDwI= =TkIY -----END PGP SIGNATURE-----
Mar 03 2007