Bug 21001 – Private alias becomes public if used before declaration
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-07-01T12:33:41Z
Last change time
2020-10-11T20:29:52Z
Assigned to
No Owner
Creator
FeepingCreature
Comments
Comment #0 by default_357-line — 2020-07-01T12:33:41Z
Consider the following code ( https://run.dlang.io/is/mn75WZ ):
--- a.d
module a;
private struct S { Alias member; }
private alias Alias = int;
--- b.d
module b;
import a;
void main() { Alias var; }
--
Clearly this shouldn't ought to compile, but it does. Alias is publically visible as an export from a, despite being declared private.
This only seems to happen if S comes before Alias. Somehow, using the symbol early prevents it from being marked private.
Comment #1 by dlang-bot — 2020-07-02T01:40:34Z
dlang/dmd pull request #11356 "Fix issue 21001: alias protection is ignored if used before declaration." was merged into master:
- 7a3a2e3af7810c812d691d941bfe3ae892f678cd by Mathis Beer:
Fix issue 21001: alias protection is ignored if used before declaration.
https://github.com/dlang/dmd/pull/11356
Comment #2 by dlang-bot — 2020-10-11T20:29:52Z
dlang/dmd pull request #11831 "[dmd-cxx] fix Issue 21295: Add test for symbol lookup/resolve in compilation broken" was merged into dmd-cxx:
- 828a643338cf8834608227ea815d94acccdd2b77 by Mathis Beer:
[dmd-cxx] Fix issue 21001: alias protection is ignored if used before declaration.
https://github.com/dlang/dmd/pull/11831