Thread overview
[Issue 23855] traits getOverloads returns overload when one of the symbols is a templatized function
Apr 24, 2023
FeepingCreature
Apr 24, 2023
FeepingCreature
Apr 24, 2023
FeepingCreature
Apr 24, 2023
FeepingCreature
April 24, 2023
https://issues.dlang.org/show_bug.cgi?id=23855

FeepingCreature <default_357-line@yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
April 24, 2023
https://issues.dlang.org/show_bug.cgi?id=23855

--- Comment #1 from FeepingCreature <default_357-line@yahoo.de> ---
Note: this is not a matter of the "includeTemplates" argument to `getOverloads`. If I set that to `true`, I still cannot actually get the attributes of the member symbols - though I get a tuple of two in that case.

The weird thing is that `pragma(msg, member.mangleof)` suggests that `getOverloads selects the right functions, but I still get the deprecation warning on both of them. Maybe it's the deprecation that's confused?

--
April 24, 2023
https://issues.dlang.org/show_bug.cgi?id=23855

--- Comment #2 from FeepingCreature <default_357-line@yahoo.de> ---
Far as I can tell, `__traits(getOverloads)` just doesn't get rid of the overloadness of the template or function correctly. `td.funcroot` is set, `fd.overnext` is set, but `__traits(getOverloads)` only zeroes `td.overnext`.

--
April 24, 2023
https://issues.dlang.org/show_bug.cgi?id=23855

--- Comment #3 from FeepingCreature <default_357-line@yahoo.de> ---
Okay, I can't work this out on my own, but it's *something* about `static foreach`: `alias udas = __traits(getAttributes, overloads[0]);` works. Somehow the loop variable in `static foreach` ends up in the original module symbol, `overnext` included: it's supposed to be a `FuncAliasDeclaration` from `getOverloads`, but even though it creates the tuple right, somewhere in the `static foreach` code, DMD gets rid of it again.

--
July 29
https://issues.dlang.org/show_bug.cgi?id=23855

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #4 from Nick Treleaven <nick@geany.org> ---
> Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `test`

I get no deprecation message with recent dmd.

> Note: this is not a matter of the "includeTemplates" argument to `getOverloads`. If I set that to `true`, I still cannot actually get the attributes of the member symbols

This works:

@1
void test()() { }
@2
void test(int) { }

void main() {
    alias thisModule = __traits(parent, main);
    alias overloads = __traits(getOverloads, thisModule, "test", true);
    static foreach (member; overloads) {
        pragma(msg, __traits(getAttributes, member));
    }
}

--