D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20054 - getSymbolsByUDA no longer works on modules
Summary: getSymbolsByUDA no longer works on modules
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
: 20188 (view as issue list)
Depends on:
Blocks:
 
Reported: 2019-07-15 12:59 UTC by JR
Modified: 2019-12-01 23:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description JR 2019-07-15 12:59:56 UTC
I use this heavily to iterate module-level functions[1].

import std.traits;

struct UDA;

@UDA
void foo() {}

void main()
{
    alias funs = getSymbolsByUDA!(mixin(__MODULE__), UDA);
}

> C:\cygwin\home\zorael\work\result\bin\..\import\std\traits.d(8356): Error: template instance `isAggregateType!(uda)` does not match template declaration `isAggregateType(T)`
> uda.d(10):        while looking for match for `getSymbolsByUDA!(uda, UDA)`

Offending commit:

commit f07517ac648a933d998bc6a53af7dc55c9d48daf
Author: The Dlang Bot <code+dlang-bot@dawg.eu>
Date:   Wed Jul 10 11:57:39 2019 +0200

    phobos: Merge pull request #7100 from RazvanN7/fix_issue_19105

    https://github.com/dlang/phobos/pull/7100

    Fix Issue 19105 - Bogus recursive template expansion via getSymbolsByUDA
    merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>

[1]: https://github.com/zorael/kameloso/blob/25cee1b7/source/kameloso/plugins/common.d#L955
Comment 1 Simen Kjaeraas 2019-07-15 13:42:58 UTC
The fix implemented for issue 19105 is just plain wrong, as the issue isn't fixed:

import std.traits;

struct A(Args...) {}

struct S1 {
    // Recursive template expansion
    alias C = A!( getSymbolsByUDA!(S1, A) );
}
struct S2 {
    // precompute the result:
    alias tmp = getSymbolsByUDA!(S2, A);
    // No recursive template expansion
    alias C = A!( getSymbolsByUDA!(S2, A) );
}

Reduced test case:

template test(alias T) {
    enum i = __traits(compiles, __traits(getMember, T, "C"));
    alias test = int;
}

struct A(Args...) {}

struct S1 {
    // Recursive template expansion
    alias C = A!(test!S1);
}
struct S2 {
    // No error
    alias a = test!S2;
    alias C = A!(test!S2);
}
Comment 2 Dlang Bot 2019-08-29 08:25:01 UTC
@Biotronic updated dlang/phobos pull request #7158 "Revert "Fix Issue 19105 - Bogus recursive template expansion via getS…" fixing this issue:

- Fix issue 20054 - getSymbolsByUDA no longer works on modules

https://github.com/dlang/phobos/pull/7158
Comment 3 Simen Kjaeraas 2019-09-01 20:59:23 UTC
*** Issue 20188 has been marked as a duplicate of this issue. ***
Comment 4 Dlang Bot 2019-12-01 23:40:16 UTC
dlang/phobos pull request #7158 "Revert "Fix Issue 19105 - Bogus recursive template expansion via getS…" was merged into stable:

- 2a2018cf34e8b410f40be53c6068b84121888af7 by Simen Kjærås:
  Fix issue 20054 - getSymbolsByUDA no longer works on modules

https://github.com/dlang/phobos/pull/7158