digitalmars.D.bugs - [Issue 2699] New: template functions doesn't specialize types of arguments correctly.
- d-bugmail puremagic.com (35/35) Mar 01 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2699
- d-bugmail puremagic.com (17/17) Feb 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2699
http://d.puremagic.com/issues/show_bug.cgi?id=2699 Summary: template functions doesn't specialize types of arguments correctly. Product: D Version: 2.025 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: kk_tnr hotmail.com DMD 2.205 on Windows See this code. import std.stdio: writefln; void main( ){ int a = 1; funcA( [a] ); funcA!( typeof( [a] ))( [a] ); } void funcA( T )( T t ){ writefln( "funcA, T" ); } void funcA( T: T[] )( T[] t ){ writefln( "funcA, T: T[]" ); } It is compiled with no errors. Result: funcA, T funcA, T: T[] This means, 'funcA( [a] );' is not equal to 'funcA!( typeof( [a] ))( [a] );' Perhaps it is not a bug, but is not good spec. Thank you for your reading. --
Mar 01 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2699 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |INVALID The problem is here: void funcA( T: T[] )( T[] t ) Calling with an int[] parameter infers T to be int, which does _not_ fit the specialization. void funcA( T: U[], U )( T t ) works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2012