Bug 20054 – getSymbolsByUDA no longer works on modules
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2019-07-15T12:59:56Z
Last change time
2019-12-01T23:40:16Z
Keywords
pull
Assigned to
No Owner
Creator
JR
Comments
Comment #0 by zorael — 2019-07-15T12:59:56Z
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 <[email protected]>
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 <[email protected]>
[1]: https://github.com/zorael/kameloso/blob/25cee1b7/source/kameloso/plugins/common.d#L955
Comment #1 by simen.kjaras — 2019-07-15T13:42:58Z
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 by dlang-bot — 2019-08-29T08:25:01Z
@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 by simen.kjaras — 2019-09-01T20:59:23Z
*** Issue 20188 has been marked as a duplicate of this issue. ***
Comment #4 by dlang-bot — 2019-12-01T23:40:16Z
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