www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23500] New: std.traits.getUDAs not working properly for

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 puremagic.com
          Reporter: razvan.nitu1305 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

--
Nov 21 2022