Skip to content

Commit

Permalink
fix Issue 15177 - mixin + traits issue with 2.069 beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Oct 9, 2015
1 parent f09bb06 commit f26ae00
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/traits.d
Expand Up @@ -1049,14 +1049,23 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
//printf("\t[%i] %s %s\n", i, sm->kind(), sm->toChars());
if (sm.ident)
{
if (sm.ident.string[0] == '_' && sm.ident.string[1] == '_' && sm.ident != Id.ctor && sm.ident != Id.dtor && sm.ident != Id.__xdtor && sm.ident != Id.postblit && sm.ident != Id.__xpostblit)
if (sm.ident.string[0] == '_' &&
sm.ident.string[1] == '_' &&
sm.ident != Id.ctor &&
sm.ident != Id.dtor &&
sm.ident != Id.__xdtor &&
sm.ident != Id.postblit &&
sm.ident != Id.__xpostblit)
{
return 0;
}
if (sm.ident == Id.empty)
{
return 0;
}
if (sm.isTypeInfoDeclaration()) // Bugzilla 15177
return 0;

//printf("\t%s\n", sm->ident->toChars());
/* Skip if already present in idents[]
*/
Expand All @@ -1065,11 +1074,9 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
Identifier id = (*idents)[j];
if (id == sm.ident)
return 0;
debug
{
// Avoid using strcmp in the first place due to the performance impact in an O(N^2) loop.
assert(strcmp(id.toChars(), sm.ident.toChars()) != 0);
}

// Avoid using strcmp in the first place due to the performance impact in an O(N^2) loop.
debug assert(strcmp(id.toChars(), sm.ident.toChars()) != 0);
}
idents.push(sm.ident);
}
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/imports/test15117a.d
@@ -0,0 +1,9 @@
module imports.test15117a;

struct AssertResult {}

auto test_usr_1()
{
// 2. generate TyepInfoStructDeclaration
auto x = typeid(AssertResult);
}
23 changes: 23 additions & 0 deletions test/compilable/test15177.d
@@ -0,0 +1,23 @@
// REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
// EXTRA_SOURCES: imports/test15117a.d

import users = imports.test15117a;

void RunApiTest(T...)()
{
foreach (name; __traits(allMembers, users))
{
// 3. list the name of TyepInfoStructDeclaration,
// but it's just internal symbol and invisible.
mixin("alias func = users . " ~ name ~ ";");
}
}

void main()
{
// 1. run semantic3 of users.test_usr_1
users.test_usr_1();

RunApiTest!();
}

0 comments on commit f26ae00

Please sign in to comment.