On Thursday, 16 June 2022 at 13:27:25 UTC, frame wrote:
But it looks like a compiler bug since the output of
`getSymbolsByUDA` is just an alias sequence and nothing should
happen before consuming it?
Yes, this is a compiler bug. I've filed a report for it on
bugzilla:
On Thursday, 16 June 2022 at 09:29:36 UTC, Arafel wrote:
Classes can have static members just as structs, so I don't
think you always need an instance for a class either.
Well, ok.
So if you call `getMember` from a member function, it adds the
hidden `this` reference, and this has subtle
On 16/6/22 10:55, frame wrote:
On Thursday, 16 June 2022 at 08:23:20 UTC, Arafel wrote:
This is not true. `getMember` can return the symbol to the instance or
the type/alias, depending if you pass `this` or `Def`. The last is static.
It makes no sense to use the attribute from a class
On Thursday, 16 June 2022 at 08:23:20 UTC, Arafel wrote:
As you can see, it's `getMember` who is returning a reference
to the `this` instance. In my view, this is a bug according the
documentation and examples [1]. It might be that classes behave
differently, but then it should be documented.
On 15/6/22 14:26, cc wrote:
```d
import std.traits;
class XML {}
class Def {
@XML {
int x;
int y;
}
int z;
this() {
static foreach (sym; getSymbolsByUDA!(Def, XML)) {
}
}
}
void main() {
auto def = new Def;
}
```
```
On Wednesday, 15 June 2022 at 12:26:40 UTC, cc wrote:
Why doesn't this work? There is nothing in the foreach body.
```d
alias ALL = getSymbolsByUDA!(Def, XML);
pragma(msg, ALL.stringof);
```
reports `tuple(this.x, this.y)`. Why is `this.` added?
I can only answer this partially, I guess
```d
import std.traits;
class XML {}
class Def {
@XML {
int x;
int y;
}
int z;
this() {
static foreach (sym; getSymbolsByUDA!(Def, XML)) {
}
}
}
void main() {
auto def = new Def;
}