D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21001 - Private alias becomes public if used before declaration
Summary: Private alias becomes public if used before declaration
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-01 12:33 UTC by FeepingCreature
Modified: 2020-10-11 20:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description FeepingCreature 2020-07-01 12:33:41 UTC
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 Dlang Bot 2020-07-02 01:40:34 UTC
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 Dlang Bot 2020-10-11 20:29:52 UTC
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