getSymbolsByUDA in constructor/member functions
cc
cc at nevernet.com
Wed Jun 15 12:26:40 UTC 2022
```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;
}
```
```
test.d(12): Error: value of `this` is not known at compile time
test.d(12): Error: value of `this` is not known at compile time
```
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?
More information about the Digitalmars-d-learn
mailing list