Bug 16044 – __traits(allMembers) returns empty tuple for subpackages
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-18T16:47:28Z
Last change time
2021-04-09T10:29:17Z
Keywords
pull
Assigned to
No Owner
Creator
Steven Dwy
Comments
Comment #0 by yoplitein — 2016-05-18T16:47:28Z
Given abc/def/package.d:
---
module abc.def;
int xyz;
static this()
{
pragma(msg, __traits(allMembers, mixin(__MODULE__)));
}
---
When compiled with `dmd -c abc/def/package.d`, it should print `tuple("object", "xyz", "_staticCtor1")` but instead only prints an empty tuple.
For top level packages, it works as expected.
Comment #1 by crimaniak — 2017-05-01T02:20:43Z
For DMD64 D Compiler 2.074.0 result is:
abc/def/package.d-mixin-7(7): Deprecation: package abc.def is not accessible here, perhaps add 'static import abc.def;'
tuple()
So abc.def package is not accessible from abc/def/package.d
But accessible if I move/rename file to abc/def.d and result is tuple("object", "xyz", "_staticCtor1")
So it seems, for now, the problem is in the availability of the module, not in the allMembers trait.
Comment #2 by dlang-bot — 2020-08-25T02:02:54Z
@NilsLankila created dlang/dmd pull request #11619 "fix issue 16044 - __traits(allMembers) returns empty tuple for subpackages" fixing this issue:
- fix issue 16044 - __traits(allMembers) returns empty tuple for subpackages
This fix is only for the members that are not imports.
There are other issues opened (11595, 17057, 20008) for that.
https://github.com/dlang/dmd/pull/11619
Comment #3 by dlang-bot — 2020-08-25T05:21:30Z
dlang/dmd pull request #11619 "fix issue 16044 - __traits(allMembers) returns empty tuple for subpackages" was merged into master:
- 60a7248fda7528eb0f459bdcc50c74f71edf960a by Nils Lankila:
fix issue 16044 - __traits(allMembers) returns empty tuple for subpackages
This fix is only for the members that are not imports.
There are other issues opened (11595, 17057, 20008) for that.
https://github.com/dlang/dmd/pull/11619
Comment #4 by dlang-bot — 2021-04-09T10:29:17Z
dlang/dmd pull request #12411 "[dmd-cxx] fix Issue 21813 - [REG-master] Bootstrap broken from dmd-cxx baseline" was merged into dmd-cxx:
- 11a067808e5f11c762262cfa04ad5c5e44f49814 by Nils Lankila:
[dmd-cxx] fix issue 16044 - __traits(allMembers) returns empty tuple for subpackages
https://github.com/dlang/dmd/pull/12411