digitalmars.D.bugs - [Issue 415] New: conflicting template functions overloads
- d-bugmail puremagic.com (25/25) Oct 09 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (7/7) Oct 09 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (19/19) Oct 09 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (10/10) Oct 09 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (13/13) Oct 09 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (14/14) Oct 16 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
- d-bugmail puremagic.com (22/22) Nov 21 2006 http://d.puremagic.com/issues/show_bug.cgi?id=415
http://d.puremagic.com/issues/show_bug.cgi?id=415 Summary: conflicting template functions overloads Product: D Version: 0.169 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: benoit tionex.de void arraycopy( T )( T[] src, T[] trg, int length ){ } void main(){ char[] a, b; arraycopy( a, b, 1 ); //(1) arraycopy( a, b, a.length ); //(2) } I don't want to change the main() content: (2) causes an error because length is uint. if I change the signature of arraycopy to "( T[], T[], uint)", (1) causes an error. If I supply both variations, they conflict. They should not. --
Oct 09 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --
Oct 09 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |golovanov_alexey mail.ru void arraycopy( T,U )( T[] src, T[] trg, U length ){ static if (is(U: int)) //now uint ,int and other type can implicitly cast to //int can be processed { // do ur job here } } void main(){ char[] a, b; arraycopy( a, b, 1 ); //(1) arraycopy( a, b, a.length ); //(2) } --
Oct 09 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | ah, u mean the problem is they should not conflict... umm yep , they shouldn't conflict if they can't be implicitly cast to one type. --
Oct 09 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 umm, i think i should state that more clear, i guess the problem is dmd not doing enough distinguish check when the template in this collapsed form. actually if i write template arraycopy(T) { arraycopy(T[] a, T[] b, int length) arraycopy(T[] a, T[] b, uint length) } is ok but the main func in ur example need to modified, so that's not a good idea. --
Oct 09 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 If I may, a more illustrative case: -------- void func(int a) { } void tfunc()(int a) { } void test() { func(cast(uint) 2); // OK tfunc!()(cast(uint) 2); // OK tfunc(cast(uint) 2); // IFTI breakage } --
Oct 16 2006
http://d.puremagic.com/issues/show_bug.cgi?id=415 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID The language is working as defined. All the examples have easy solutions. Let's take the last one: void tfunc()(int a) { } void test() { tfunc!()(cast(uint) 2); // OK tfunc(cast(uint) 2); // IFTI breakage } Fix: void tfunc(T)(T a) { } Or: void tfunc()(int a) { } void tfunc(dummy=void)(uint a) { } --
Nov 21 2006