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

Richard Cattermole <alphaglosi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaglosi...@gmail.com

--- Comment #1 from Richard Cattermole <alphaglosi...@gmail.com> ---
This was rediscovered by a user on Discord.

The deprecation message wasn't very good.

/usr/include/dmd/phobos/std/traits.d(8514): Deprecation:
__traits(getAttributes) may only be used for individual functions, not overload
sets such as: __ctor

I modified the example here to demonstrate how to change their code:

```d
import std.traits;                                                              

void main() {
    enum attr1;
    enum attr2;

    struct A {   
        @attr1
        void foo();
        @attr2
        void foo(int a); 
    }   

    static foreach(overload; __traits(getOverloads, A, "foo")) {
        pragma(msg, getUDAs!(overload, attr2));
    }
}
```

That deprecation message should be improved with more context, although perhaps
there are some improvements that could be done more broadly like giving more
context (i.e. what triggered that instantiation of getUDAs).

--

Reply via email to