I want to get the UDAs for for a function parameter. Here the
test code and I got some errors:
source/app.d(29,33): Error: first argument is not a symbol
source/app.d(39,15): Error: template instance app.test!(ClassA)
error instantiating
How can I fix this? Would this be a bug? Thanks.
=====================
import std.stdio;
import std.traits;
import std.meta;
struct Length {
int a;
int b;
}
class ClassA {
void test(@Length(1, 9) int len, @Length(2, 4) int size) {
writeln("It's OK");
}
void test(string name) {
writeln("Can't be compiled");
}
}
string test(T)() {
string str;
alias currentMembers = __traits(getOverloads, T, "test");
static foreach(member; currentMembers) {{
alias Params = Parameters!(member);
static foreach(i; 0 .. Params.length)
{{
alias ThisParameter = Params[i .. i + 1];
static foreach(uda; __traits(getAttributes,
ThisParameter)) {
str ~= uda.stringof ~ "\n";
}
}}
}}
return str;
}
void main() {
enum aa = test!(ClassA);
writeln(aa);
}