www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Template bug

Compile these two files together and 
everything is ok.  Compile them separately
and there is a linker error.

test.obj(test)
Error 42: Symbol Undefined _D5temp129foo_i__20__D4test7thefuncFiZb3fooFiZb
--- errorlevel 1

//---- test -----

import temp1;

bool thefunc(int v)
{
return v == 3;
}

void main(char[][] argv)
{
bar!(int,thefunc)(5,3);
}
//---- temp1 -----
template foo(Type,alias Func)
{
bool foo(Type v)
{
return Func(v);
}
}

template bar(Type,alias Func)
{
void bar(Type v, Type a)
out
{
assert(foo!(Type,Func)(v));
}
body
{
v = a;
}
}

//---- test.d -----
import temp1;

bool thefunc(int v)
{
return v == 3;
}

void main(char[][] argv)
{
bar!(int,thefunc)(5,3);
}
Jul 06 2004