www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Overloading function with a generic function fails

reply Abid H. Mujtaba <abid.naqvi83 gmail.com> writes:
This is another example from "The D Programming Language" by Andrei
Alexandrescu. Compiling the following:

// Code in test.d:

void transmogrify( uint x ) {}
void transmogrify( long x ) {}
void transmogirfy(T)( T x ) {}

unittest {

  transmogrify( 42 ) ;
}

fails with the following error (when compiled with 'rdmd --main -unittest
test.d' :

test.d(3): Error: template test.transmogrify(T) conflicts with function
test.transmogrify at test.d(1)

As I understood it the D compiler is capable of setting up a partial ordering
of functions and choosing one of the three overloaded functions based upon how
it was called.

Note: The example above works if I remove the generic function that is
overloading works for explicit types but not for generic types.
May 12 2011
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Known issue, it's in bugzilla somewhere.
May 12 2011
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 5/12/11 12:27 PM, Andrej Mitrovic wrote:
 Known issue, it's in bugzilla somewhere.
Yah, partial ordering is not fully implemented across template and non-template functions. Thanks Abid for the report. Andrei
May 12 2011