Non-consistent implicit function template specializations

Rekel paultjeadriaanse at gmail.com
Tue Aug 17 09:59:53 UTC 2021


When using implicit function templates, identical specialization 
yield different results.
Example:

```d
template TFoo(T)        { void foo(){writeln("1");} } // #1
template TFoo(T : T[])  { void foo(){writeln("2");} } // #2

void foo(T)(){
	writeln("1");
}

void foo(T : T[])(){
	writeln("1");
}

void main(string[] args) { // Works
	TFoo!(int).foo();            // "1"
	TFoo!(double[]).foo();       // "2"
	foo!(int)();            // "1"
	foo!(double[])();       // "1" !
}
```

I'm fairly certain the last call _should_ yield "2", yet it does 
not.
Should I submit a bugreport? And will that even help? There's 
even 'NEW' bugs from 2016 :'c

---

Interestingly enough, it seems I've made a previous thread about 
this in January 
(https://forum.dlang.org/post/zudtiruaxdfdwcjennmr@forum.dlang.org), though in it I state `TFoo!(uint[]) yields the array version`, which as can be seen from the example above, is not or no longer true.
Sadly I'm having issues with template arguments more often 
(https://forum.dlang.org/post/xkgpheuhohbffzgdbqhb@forum.dlang.org)
And I sadly don't see any improvement to this happening any time 
in the future. Even bugs don't seem to get fixed in any timely 
manner (Not meant as an insult, just being realistic :/).


More information about the Digitalmars-d-learn mailing list