Skip to content

Commit

Permalink
Fix Issue 18624 - wrong behavior of getSymbolsByUDA if one of the sym…
Browse files Browse the repository at this point in the history
…bols having the UDA is a function
  • Loading branch information
Spoov committed Mar 17, 2018
1 parent a2b1380 commit 9ab9b01
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -7877,7 +7877,8 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
else static if (isFunction!member)
{
enum hasSpecificUDA(alias member) = hasUDA!(member, attribute);
alias getSymbolsByUDAImpl = Filter!(hasSpecificUDA, __traits(getOverloads, symbol, names[0]));
alias overloadsWithUDA = Filter!(hasSpecificUDA, __traits(getOverloads, symbol, names[0]));
alias getSymbolsByUDAImpl = AliasSeq!(overloadsWithUDA, tail);
}
else static if (hasUDA!(member, attribute))
{
Expand Down Expand Up @@ -8020,6 +8021,21 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
static assert(res[0].stringof == "a");
}

// #18624: getSymbolsByUDA produces wrong result if one of the symbols having the UDA is a function
@safe unittest
{
enum Attr;
struct A
{
@Attr void a();
@Attr void a(int n);
void b();
@Attr void c();
}

static assert(getSymbolsByUDA!(A, Attr).stringof == "tuple(a, a, c)");
}

/**
Returns: $(D true) iff all types $(D T) are the same.
*/
Expand Down

0 comments on commit 9ab9b01

Please sign in to comment.