[Issue 23473] Need a way to disassemble an overload function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 10 11:58:26 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23473

--- Comment #1 from FeepingCreature <default_357-line at yahoo.de> ---
Oops, pressed return too soon.

Consider this code:

--- b.d
void first(int) { }
--- a.d
import b : foo = first;
import c : foo = second;

void main() {
    foo(1); // works
    foo("hello"); // works
    alias overloads = __traits(getOverloads, __traits(parent, foo),
__traits(identifier, foo));
    static assert(overloads.length == 2);
}
--- c.d
void second(string) { }

Because the overload we want is not of a struct or class, we use the common
pattern, for example used in https://dlang.org/blog/category/algorithms/ , to
get "the module" the overload is in. But there is no such module, because the
overload is formed from two other modules that don't even use the same
identifier for it.

There should be an overload or trait alternative to getOverloads that operates
on a symbol directly.

--


More information about the Digitalmars-d-bugs mailing list