digitalmars.D.bugs - [Issue 21508] New: private class p in file p.d visible outside the
- d-bugmail puremagic.com (36/36) Dec 27 2020 https://issues.dlang.org/show_bug.cgi?id=21508
https://issues.dlang.org/show_bug.cgi?id=21508 Issue ID: 21508 Summary: private class p in file p.d visible outside the file (module) Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kdevel vogtner.de According to Issue 1441 private classes should not be visible outside the module it is defined in. If the class is named after the basename of the module's file the protection does not work: ---p.d module p; private class p {} --- ---m.d unittest { import p; import std.typecons; // p.p is private, code should not compile static assert (! __traits (compiles, (new p))); } --- $ dmd -unittest -main -run m m.d(5): Error: static assert: !__traits(compiles, new p) is false Issue mentioned in http://forum.dlang.org/thread/vdfrhsrmbjyopzuiufhd forum.dlang.org If the file p.d is renamed in say P.d and import p is changed to import P the unittest passes. --
Dec 27 2020