Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry #4578

Merged
merged 1 commit into from Apr 11, 2015

Conversation

Geod24
Copy link
Member

@Geod24 Geod24 commented Apr 11, 2015

The problem was that StaticAssert had an empty identifier instead of a null one, which is expected by allMember.
By the way is there a reason why Id::empty is empty string instead of NULL ?

@9rnsr
Copy link
Contributor

9rnsr commented Apr 11, 2015

Id::empty is used to avoid NULL check for the ident member access.

ident == NULL is used for the anonymous members which not yet semantic analysis finished. For example, an anonymous class creation new class (arguments) { ... } internally defines a ClassDeclaration with NULL ident, then it will be filled by the unique name in ClassDeclaration::semantic().

@@ -998,6 +998,7 @@ Expression *semanticTraits(TraitsExp *e, Scope *sc)
#endif
}

assert(strlen(sm->toChars()) > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using strlen for the Identifier object is costly operation. Instead of that, you can use more lightweight comparison sm->ident != Id::empty.

@Geod24 Geod24 force-pushed the fix-14375 branch 3 times, most recently from 6f1f186 to 2dfede5 Compare April 11, 2015 14:21
@Geod24
Copy link
Member Author

Geod24 commented Apr 11, 2015

Thanks for the explanation!
I changed the commit accordingly to just exclude Id::empty.

Btw: Should I submit this against stable as well / instead ?

@9rnsr
Copy link
Contributor

9rnsr commented Apr 11, 2015

LGTM.

Btw: Should I submit this against stable as well / instead ?

Even so, we can cherry-pick the commit later into stable branch.

@9rnsr
Copy link
Contributor

9rnsr commented Apr 11, 2015

Auto-merge toggled on

9rnsr added a commit that referenced this pull request Apr 11, 2015
Fix issue 14375 - static assert leads to __traits(allMembers) retuning an extra empty entry
@9rnsr 9rnsr merged commit 714d1b3 into dlang:master Apr 11, 2015
@Geod24 Geod24 deleted the fix-14375 branch June 27, 2018 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants