D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9986 - ModuleInfo.importedModules doesn't work
Summary: ModuleInfo.importedModules doesn't work
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-24 20:07 UTC by Timothee Cour
Modified: 2022-11-16 04:37 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timothee Cour 2013-04-24 20:07:04 UTC
running this gives
["std.stdio"]
instead of:
["std.stdio", "std.algorithm", "std.traits"]
Is that intended? bug?
also it's in fact in ModuleInfo.Old so is that deprecated? If so it should be marked as such.

How else to get same functionality?

----
module bugs.bug_2013_04_24_19_55_21;

import std.algorithm;
import std.stdio;
import std.traits;

void main(){
	foreach(a; ModuleInfo) {
		if(a.name!=moduleName!a)
			continue;
		auto b=a.importedModules;
		writeln(b.map!`a.name`);	
	}
}
----
Comment 1 Stanislav Blinov 2018-11-24 09:24:39 UTC
Up to      2.062  : Success with output: ["std.stdio"]
2.063   to 2.064  : Success with output: ["std.algorithm", "std.stdio", "std.traits"]
           2.065.0: Success with output: ["std.stdio"]
           2.066.0: Success with output: ["std.algorithm", "std.stdio", "std.traits"]
2.067.1 to 2.074.1: Success with output: ["std.stdio"]
Since      2.075.1: Success with output: []

Regression?..
Comment 2 Richard (Rikki) Andrew Cattermole 2022-11-16 04:37:42 UTC
importedModules is emitted based upon need.

It is used for module constructors being called in the right order.

The output right now is:

```
["std.array", "core.memory", "core.internal.array.utils"]
```

Unfortunately, you cannot use this for reflection purposes, as ModuleInfo is not always emitted (its bloat usually).