[Issue 19590] New: Impossible to iterate imported packages with allMembers.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 16 06:33:52 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19590

          Issue ID: 19590
           Summary: Impossible to iterate imported packages with
                    allMembers.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

Repro:

module foo;

import std.stdio;
import std.string;

// This will indicate the existence of a package "std".
pragma(msg, __traits(allMembers, foo).stringof);

// This, however, will not indicate two modules "stdio" and "string", but
rather some other symbols, whose source is unclear.
pragma(msg, __traits(allMembers, std).stringof);

Furthermore, even if this worked it would not give an avenue to explore imports
by *other* packages, since, for instance, "std.stdio.std" is not a legitimate
symbol even if std.stdio was imported.

For this reason, I believe that allMembers should never return packages, only
complete modules. In other words, __traits(allMembers, foo) should return
"std.stdio" and "std.string".

Complication: what about renamed imports, such as import std.stdio : print =
writefln;? They don't show up either, and it's not clear how they *should* show
up. Make them appear as a member "print" of the current module, and it becomes
difficult to determine their source module.

A possible solution may be traits such as isImport and getDeclaredIdentifier.

--


More information about the Digitalmars-d-bugs mailing list