Skip to content

Commit 6b2176e

Browse files
committed
Fix Issue 23977 - [REG2.102] cannot use getSymbolsByUDA on template struct with alias member
1 parent 92dc5a4 commit 6b2176e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

std/traits.d

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8910,9 +8910,9 @@ template getSymbolsByUDA(alias symbol, alias attribute)
89108910
static assert(is(getSymbolsByUDA!(X, X) == AliasSeq!()));
89118911
}
89128912

8913-
// https://issues.dlang.org/show_bug.cgi?id=23776
89148913
@safe pure nothrow @nogc unittest
89158914
{
8915+
// https://issues.dlang.org/show_bug.cgi?id=23776
89168916
struct T
89178917
{
89188918
struct Tag {}
@@ -8932,6 +8932,18 @@ template getSymbolsByUDA(alias symbol, alias attribute)
89328932
}
89338933
alias xcomponents = getSymbolsByUDA!(X, X.Tag);
89348934
static assert(xcomponents.length > 0);
8935+
8936+
// https://issues.dlang.org/show_bug.cgi?id=23977
8937+
struct S(string str)
8938+
{
8939+
alias strstr = str;
8940+
8941+
int i;
8942+
}
8943+
8944+
static struct A {}
8945+
8946+
assert((getSymbolsByUDA!(S!("a"), A)).length == 0);
89358947
}
89368948

89378949
// getSymbolsByUDA produces wrong result if one of the symbols having the UDA is a function
@@ -8991,7 +9003,10 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
89919003

89929004
// Filtering not compiled members such as alias of basic types.
89939005
static if (isAliasSeq!member ||
8994-
(isType!member && !isAggregateType!member && !is(member == enum)))
9006+
// exclude basic types and derived types
9007+
(isType!member && !isAggregateType!member && !is(member == enum)) ||
9008+
// exclude aliases to expressions such as string literals
9009+
__traits(compiles, { auto ex = member; }))
89959010
{
89969011
alias getSymbolsByUDAImpl = tail;
89979012
}

0 commit comments

Comments
 (0)