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 23776 - getSymbolsByUDA fails to fetch symbols from module #8716

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

RazvanN7
Copy link
Collaborator

No description provided.

@RazvanN7 RazvanN7 added the Regression PRs that fix regressions label Mar 13, 2023
@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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

Auto-close Bugzilla Severity Description
23776 regression getSymbolsByUDA fails to fetch symbols from module

Testing this PR locally

If 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 Show resolved Hide resolved
std/traits.d Show resolved Hide resolved
std/traits.d Outdated
Comment on lines 8845 to 8846


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor

@pbackus pbackus left a 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 enums 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))
Copy link
Contributor

@pbackus pbackus Mar 13, 2023

Choose a reason for hiding this comment

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

Suggested change
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.

@RazvanN7
Copy link
Collaborator Author

@pbackus Thanks! Should be good now.

@ibuclaw ibuclaw dismissed maxhaton’s stale review March 15, 2023 01:47

Checked unittest, and it's fine.

@dlang-bot dlang-bot merged commit 67a47cf into dlang:stable Mar 15, 2023
kinke added a commit to symmetryinvestments/ldc that referenced this pull request Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Bug Fix Regression PRs that fix regressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants