D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16044 - __traits(allMembers) returns empty tuple for subpackages
Summary: __traits(allMembers) returns empty tuple for subpackages
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2016-05-18 16:47 UTC by Steven Dwy
Modified: 2021-04-09 10:29 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 Steven Dwy 2016-05-18 16:47:28 UTC
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 Alexey Kulentsov 2017-05-01 02:20:43 UTC
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 Dlang Bot 2020-08-25 02:02:54 UTC
@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 Dlang Bot 2020-08-25 05:21:30 UTC
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 Dlang Bot 2021-04-09 10:29:17 UTC
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