[Issue 23500] New: std.traits.getUDAs not working properly for overloads

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 21 14:14:53 UTC 2022


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

          Issue ID: 23500
           Summary: std.traits.getUDAs not working properly for overloads
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: razvan.nitu1305 at gmail.com

import std.traits;                                                              

@safe void main()
{
    enum attr1;
    enum attr2;

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

    pragma(msg, getUDAs!(A.foo, attr2));
}

I would expect this to print (attr2), however, it does not print anything.
If I change the example to get attr1 then it works. I expect that for overload
sets, getUDAs should iterate through the overloads and report if any of the
overloads has the given udas. Right now, it just reports the udas for the first
overload it finds.

This has been discovered while trying to fix __traits(getAttributes) in the
compiler : https://github.com/dlang/dmd/pull/14554

--


More information about the Digitalmars-d-bugs mailing list