Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSymbolsByUDA ignores template functions #10546

Open
dlangBugzillaToGithub opened this issue Apr 3, 2024 · 1 comment
Open

getSymbolsByUDA ignores template functions #10546

dlangBugzillaToGithub opened this issue Apr 3, 2024 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

johanengelen reported this on 2024-04-03T23:35:14Z

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

CC List

Description

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;
    }
}
```
@dlangBugzillaToGithub
Copy link
Author

issues.dlang (@jmdavis) commented on 2024-04-05T22:27:01Z

Yeah, __traits(getOverloads, ...) won't give you templated overloads unless you tell it to - and in the general case, it really isn't going to work well to get attributes from a templated function because of attribute inference. However, for UDAs, they should be there regardless.

@thewilsonator thewilsonator removed the OS:Mac OS Issues Specific to Mac OS label Dec 5, 2024
@LightBender LightBender removed the P1 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants