-
-
Notifications
You must be signed in to change notification settings - Fork 701
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 23776 - getSymbolsByUDA fails to fetch symbols from module #8716
Conversation
Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + phobos#8716" |
std/traits.d
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with this change it still fails to fetch enum
s with UDAs. Here's the failing test case:
@safe pure nothrow @nogc unittest
{
struct T
{
struct Tag {}
@Tag enum MyEnumA;
@Tag enum MyEnumB;
@Tag enum MyEnumC;
}
alias components = getSymbolsByUDA!(T, T.Tag);
static assert(components.length > 0);
}
std/traits.d
Outdated
@@ -8866,7 +8880,7 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...) | |||
alias member = __traits(getMember, symbol, names[0]); | |||
|
|||
// Filtering not compiled members such as alias of basic types. | |||
static if (isAliasSeq!member || isType!member) | |||
static if (isAliasSeq!member || (isType!member && !isAggregateType!member)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static if (isAliasSeq!member || (isType!member && !isAggregateType!member)) | |
static if (isAliasSeq!member || (isType!member && !isAggregateType!member && !is(member == enum))) |
User-defined types include both aggregates and enums. Maybe we should add an isUserDefinedType
template to help people avoid this mistake in the future.
@pbackus Thanks! Should be good now. |
No description provided.