www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - getSymbolsByUDA toSymbols error instantiating

reply Oleg B <code.viator gmail.com> writes:
Hello. I have this code:

```d
import std.traits;

enum myuda;

class A {  myuda int x; }

class B : A
{
      myuda int some;
     void foo() { foreach (s; getSymbolsByUDA!(typeof(this), 
myuda)) {} }
}

void main() { (new B).foo(); }
```

And have this error:

```
% rdmd uda_symbols.d
/usr/include/dmd/phobos/std/traits.d-mixin-7250(7250): Error: 
template instance AliasSeq!(some, x) AliasSeq!(some, x) is nested 
in both B and A
/usr/include/dmd/phobos/std/traits.d(7259): Error: template 
instance std.traits.getSymbolsByUDA!(B, myuda).toSymbols!("some", 
"x") error instantiating
uda_symbols.d(10):        instantiated from here: 
getSymbolsByUDA!(B, myuda)
```

If I understand correctly it's happens because code in std.traits 
can't choose between A.x and B.x, but I don't understand why. 
It's a bug or it's has a more complex base?
Feb 27
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/27/2017 06:26 AM, Oleg B wrote:
 Hello. I have this code:

 ```d
 import std.traits;

 enum myuda;

 class A {  myuda int x; }

 class B : A
 {
      myuda int some;
     void foo() { foreach (s; getSymbolsByUDA!(typeof(this), myuda)) {} }
 }

 void main() { (new B).foo(); }
 ```

 And have this error:

 ```
 % rdmd uda_symbols.d
 /usr/include/dmd/phobos/std/traits.d-mixin-7250(7250): Error: template
 instance AliasSeq!(some, x) AliasSeq!(some, x) is nested in both B and A
 /usr/include/dmd/phobos/std/traits.d(7259): Error: template instance
 std.traits.getSymbolsByUDA!(B, myuda).toSymbols!("some", "x") error
 instantiating
 uda_symbols.d(10):        instantiated from here: getSymbolsByUDA!(B,
 myuda)
 ```

 If I understand correctly it's happens because code in std.traits can't
 choose between A.x and B.x, but I don't understand why. It's a bug or
 it's has a more complex base?
This looks like a bug to me. Please file it at https://issues.dlang.org/ Ali
Feb 27