Looking for a workaround

Guillaume Piolat first.last at gmail.com
Wed Apr 6 18:10:32 UTC 2022


This program fails to build:


     import std.traits: getSymbolsByUDA;

     struct MyUDA
     {
     }

     class A
     {
         @MyUDA int a;
     }

     class B : A
     {
         @MyUDA int b;
     }

     void main()
     {
         alias G = getSymbolsByUDA!(B, MyUDA);
     }



Output:


     
c:\d\ldc2-1.28.0-windows-multilib\bin\..\import\std\traits.d(8933): Error: template
     instance `AliasSeq!(b, a)` `AliasSeq!(b, a)` is nested in 
both `B` and `A`
     
c:\d\ldc2-1.28.0-windows-multilib\bin\..\import\std\traits.d(8707): Error: template
     instance `std.traits.getSymbolsByUDAImpl!(B, MyUDA, "b", "a", 
"toString", "toHash",
     "opCmp", "opEquals", "Monitor", "factory")` error 
instantiating
     main.d(19):        instantiated from here: 
`getSymbolsByUDA!(B, MyUDA)`
     Failed: 
["c:\\d\\ldc2-1.28.0-windows-multilib\\bin\\ldmd2.exe", "-v", 
"-o-", "main.d", "-I."]


Any idea how to workaround that? I really need the same UDA in 
parent and child class.


More information about the Digitalmars-d-learn mailing list