Thread overview
template class name unconsistent behavior
Sep 17, 2012
timotheecour
Sep 17, 2012
timotheecour
Sep 17, 2012
Ali Çehreli
Sep 17, 2012
timotheecour
September 17, 2012
Is that a bug?

The code below returns:

"main.A!(double).A"

if we uncomment "auto c=make!A(1.0);", we get:

"main.a!(double).A"

----
module main;
import std.stdio;
class A(T){
	T x;
	this(T x){this.x=x;}
}
auto make(alias a,T...)(T args){
	return new a!T(args);
}
void main(){
	//auto c=make!A(1.0);
	auto b=new A!double(1.0);
	writeln(typeid(b));
}
----

September 17, 2012
If this behavior is not a bug, I wonder what's the rationale, but also, how can we have such a "make" function that doesn't mess up the template class name depending on the order of which is used first (the make!T variant or the new A!T) ?
September 17, 2012
On 09/16/2012 05:08 PM, timotheecour wrote:
> Is that a bug?
>
> The code below returns:
>
> "main.A!(double).A"
>
> if we uncomment "auto c=make!A(1.0);", we get:
>
> "main.a!(double).A"
>
> ----
> module main;
> import std.stdio;
> class A(T){
> T x;
> this(T x){this.x=x;}
> }
> auto make(alias a,T...)(T args){
> return new a!T(args);
> }
> void main(){
> //auto c=make!A(1.0);
> auto b=new A!double(1.0);
> writeln(typeid(b));
> }
> ----
>

This bug must be related:

  http://d.puremagic.com/issues/show_bug.cgi?id=8579

Other bugs that are linked from that one mention an internal hash table. Apparently different objects resolve to the same key, and the value of the first key gets used from that hash table.

I don't know whether Kenji Hara's fix for the bug above also fixed this issue. I say, open a bug anyway.

Ali
September 17, 2012
done: http://d.puremagic.com/issues/show_bug.cgi?id=8674