Comment #0 by default_357-line — 2019-06-26T11:33:20Z
Consider this code: https://run.dlang.io/is/ANydDv
import std.meta;
void main()
{
alias module_ = __traits(parent, main);
static assert(anySatisfy!(isSame!main, allMembers!module_));
static assert(anySatisfy!(isSame!std, allMembers!module_));
pragma(msg, __traits(allMembers, std));
// static assert(anySatisfy!(isSame!(std.meta), allMembers!std));
}
alias allMembers(alias Sym) = staticMap!(getMember!Sym, __traits(allMembers, Sym));
template getMember(alias Sym) {
alias getMember(string ident) = __traits(getMember, Sym, ident);
}
template isSame(alias Sym1) {
enum isSame(alias Sym2) = __traits(isSame, Sym1, Sym2);
}
As can be seen by the pragma(msg) and the spectacular errors when you comment in the commented-out line, the contents of __traits(allMembers, std) are not at all things that can be written in the form "std.<member>".
Expected: tuple("meta")
Got: tuple("object", "AliasSeq", "Alias", "OldAlias", "staticIndexOf", "genericIndexOf", "Erase", "GenericErase", "EraseAll", "GenericEraseAll", "EraseAllN", "NoDuplicates", "Replace", "GenericReplace", "ReplaceAll", "GenericReplaceAll", "Reverse", "MostDerived", "DerivedToFront", "staticMap", "allSatisfy", "anySatisfy", "Filter", "templateNot", "templateAnd", "templateOr", "aliasSeqOf", "ApplyLeft", "ApplyRight", "SmartAlias", "Repeat", "staticSort", "staticMerge", "isLessEq", "staticIsSorted", "Stride", "Instantiate", "isSame", "expectType", "expectBool", "Pack")
This means it is still impossible to walk all transitive imports.
Comment #1 by b2.temp — 2020-08-25T04:16:28Z
One problem is that "std" as member of the module is actually "std.meta". It appears like that by accident and could lead to what I call symbol leaks.
The allmembers traits actually always takes the ident of a symbol but for imports this should be a FQN.
*** Issue 11595 has been marked as a duplicate of this issue. ***
Comment #4 by dlang-bot — 2023-06-20T22:17:21Z
@dkorpel created dlang/dmd pull request #15335 "Fix 20008 - __traits(allMembers) of packages is complete nonsense" fixing this issue:
- Fix 20008 - __traits(allMembers) of packages is complete nonsense
https://github.com/dlang/dmd/pull/15335
Comment #5 by dlang-bot — 2023-06-27T06:45:08Z
dlang/dmd pull request #15335 "Fix 20008 - __traits(allMembers) of packages is complete nonsense" was merged into master:
- cf7ac3326918c83ca819ee061b2f65f6fbf0de63 by Dennis Korpel:
Fix 20008 - __traits(allMembers) of packages is complete nonsense
https://github.com/dlang/dmd/pull/15335