[Issue 24480] New: getSymbolsByUDA ignores template functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 3 23:35:14 UTC 2024


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

          Issue ID: 24480
           Summary: getSymbolsByUDA ignores template functions
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: johanengelen at weka.io

Testcase:
```
struct SomeUDA {}

struct S {
    @SomeUDA S opBinary(string op: "-")(S rhs) const pure nothrow @nogc {
        return rhs;
    }
    S opBinary(string op: "*")(S dur) const pure nothrow @nogc {
        return dur;
    }
}

import std.traits;
pragma(msg, getSymbolsByUDA!(S, SomeUDA));
```

This prints "()", i.e. does not return the template function
(https://d.godbolt.org/z/Th86qvMGM).

Seems to be fixed by adding `true` on this line
https://github.com/dlang/phobos/blob/77adcadf7961dbe1177aa79be381311404a81d46/std/traits.d#L9009
(similar to the `if` condition three lines above it). However, then this
slightly modified testcase still fails:

```
struct S {
    S opBinary(string op: "-")(S rhs) const pure nothrow @nogc {
        return rhs;
    }
    @SomeUDA S opBinary(string op: "*")(S dur) const pure nothrow @nogc {
        return dur;
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list