Skip to content

Commit 2dfede5

Browse files
committed
Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry
1 parent 5855bea commit 2dfede5

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/traits.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,11 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
982982
return 0;
983983
}
984984

985+
if (sm->ident == Id::empty)
986+
{
987+
return 0;
988+
}
989+
985990
//printf("\t%s\n", sm->ident->toChars());
986991
Identifiers *idents = (Identifiers *)ctx;
987992

test/compilable/test14375.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
---
5+
*/
6+
interface IKeysAPI(string greetings) {
7+
static assert(greetings == "Hello world", greetings);
8+
}
9+
10+
void main() {
11+
foreach (method; __traits(allMembers, IKeysAPI!("Hello world"))) {
12+
static assert (method.length, "Empty string from the compiler ??");
13+
pragma(msg, method);
14+
}
15+
}

0 commit comments

Comments
 (0)