[Issue 23855] New: traits getOverloads returns overload when one of the symbols is a templatized function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 24 07:13:24 UTC 2023


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

          Issue ID: 23855
           Summary: traits getOverloads returns overload when one of the
                    symbols is a templatized function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

That's right, it's the revenge of #16206 !

```
void test()() { }
void test(int) { }

void main() {
    alias thisModule = __traits(parent, main);
    alias overloads = __traits(getOverloads, thisModule, "test");
    pragma(msg, overloads.length); // returns 1
    static foreach (member; overloads) {
        alias udas = __traits(getAttributes, member);
    }
}
```

Leads to

```
Deprecation: `__traits(getAttributes)` may only be used for individual
functions, not overload sets such as: `test`
       the result of `__traits(getOverloads)` may be used to select the desired
function to extract attributes from
```

Ie. despite two symbols existing, __traits(getOverloads) returns the combined
overload set. And for once, it's independent of order too.

--


More information about the Digitalmars-d-bugs mailing list