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.
Comment #1 by yebblies — 2012-02-19T23:36:25Z
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.