Bug 21467 – Imported modules/packages are inaccessible outside the importing module

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-12-10T17:00:37Z
Last change time
2024-12-13T19:13:26Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#19838 →

Comments

Comment #0 by maxsamukha — 2020-12-10T17:00:37Z
module b; template member(alias s, string m) { static assert(__traits(hasMember, s, m)); // passes for both x and b alias member = mixin("s.", m); // fails for b } ---- module a; import b; int x; alias x1 = member!(a, "x"); // ok alias b1 = a.b; // ok alias b2 = member!(a, "b"); // fail void main() { } ---- source/b.d-mixin-5(5,1): Error: undefined identifier b in module a source/a.d(9,12): Error: template instance b.member!(a, "b") error instantiating
Comment #1 by pro.mathias.lang — 2020-12-11T14:24:44Z
> source/b.d-mixin-5(5,1): Error: undefined identifier b in module a This is correct. `b` is not a member of `a`, it's an import. I'm tempted to mark this as `INVALID`.
Comment #2 by maxsamukha — 2020-12-11T15:10:51Z
If imports are not members, then: __traits(allMembers, importing_module) must not return imports; __traits(hasMember, importing_module, "imported_module") must return false; it must be impossible to refer to the imported module as 'importing_module.imported_module' everywhere including the importing module. Also, being an import and being a member are not conceptually exclusive. "`b` is not a member of `a`, it's an import" sounds too dogmatic to me.
Comment #3 by robert.schadek — 2024-12-13T19:13:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19838 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB