getOverloads __traits does not seem to include instances of the generic members

user1234 user1234 at 12.de
Mon Mar 2 11:48:09 UTC 2026


On Monday, 2 March 2026 at 11:23:25 UTC, monkyyy wrote:
> On Monday, 2 March 2026 at 10:53:30 UTC, user1234 wrote:
>>
>> ```d
>> void v2(T)(T t){}
>> void v2(){}
>> alias v2 = v2!int;
>>
>>> Error: template instance `v2!int` `v2!int` forward references 
>>> template declaration `v2(T)(T t)`
>
> I think thats the wrong error message but Im not convinced its 
> wrong to give an error
>
> ```d
> void v1(T)();
> alias v1= bool;//error
> ```

For this case the compiler can check whether that's for a 
function... oh crap we also have eponymous templates...

Really the problem is that we cannot grow the set, while the v0 
and v1 sets are equivalent. Or maybe in the compiler internals, 
the set is well updated, problem is that then when you iterate, 
the count is wrong...

An example more closed to a real use-case:

```d
void v3(T)(T t){}
void v3(){}

enum IncludeTemplate = true;
static if (__traits(compiles, mixin("v3(0)"))) // should add an 
instance to the set
{
     pragma(msg, "yeah were are in the branch...");
     static assert (__traits(getOverloads, mixin(__MODULE__), 
"v3", IncludeTemplate).length == 3);
}
```

According to me the test on the mixin should have for effect to 
update the overload set.


More information about the Digitalmars-d mailing list