[Issue 19590] __traits allMembers should put fully qualified names for imports

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 5 01:52:49 UTC 2020


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

--- Comment #5 from Basile-z <b2.temp at gmx.com> ---
After thinking more about the problem, I have concluded that what should be
done is to add to the AST a new Dsymbol derived class called "ImportWrapper".
It would solve the problem that the information that your in the "import
domain" is lost and without using the FQN trick, which did not respect the fact
that a sym has a single ident.

  class ImportWrapper : Dsymbol
  {
     this(Ident id, ImportWrapper iw, Module m)
     {
         super(id);
         module_ = m;
         next = iw;
     }
     ImportWrapper next;
     Module module_;   
     override Dsymbol search(const ref Loc loc, Identifier ident, int flags =
IgnoreNone)
     {
        // if .next is assigned than return whether (next.identifier == ident)
        // if .module_ is assisgned then forward result of module_.search()
     }
  }

so that for `import std.algorithm;` `allMembers` can include "std", just as now
but `getMember` on this "std" gives an ImportWrapper instance that has no
`.module_` but a `.next`. `allMember` on "std" can return "algorithm".

This way partial import in the chain is not lost and sub modules that are not
imported by the ImportStatement are not visible.

--


More information about the Digitalmars-d-bugs mailing list