Bug 10528 – Private constant (enum) properties not private

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-03T08:21:00Z
Last change time
2015-02-18T03:39:05Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
cauterite

Attachments

IDFilenameSummaryContent-TypeSize
1228testcase.dTestcase for visibility attribute bugapplication/octet-stream759

Comments

Comment #0 by cauterite — 2013-07-03T08:21:34Z
Manifest constants don't seem to honour the 'private' attribute when inside aggregate type definitions. Here's an example: /* --- module1.d --- */ private enum string ModuleData = "asdfgh"; struct Structure { static private enum string Data = "qwerty"; }; /* --- module2.d --- */ import module1; import std.stdio; void main() { writeln(ModuleData); // Error: mod1.ModuleData is private (correct) writeln(Structure.Data); // no error (incorrect) }; I can't find any reason why this might be permitted, so it seems like a bug to me. Tested using DMD v2.063.2 on WinXP.
Comment #1 by crunchengine — 2013-07-04T01:56:36Z
Created attachment 1228 Testcase for visibility attribute bug A simpler testcase, visibility attribute is completely broken, it could cause big troubles... tested on 2.063 on Windows XP, could someone test on other platforms ?
Comment #2 by henning — 2013-07-04T04:42:55Z
(In reply to comment #1) > Created an attachment (id=1228) [details] > Testcase for visibility attribute bug > > A simpler testcase, visibility attribute is completely broken, it could cause > big troubles... > > tested on 2.063 on Windows XP, could someone test on other platforms ? In D "private" and "protected" symbols are also accessible in the module they are declared in. So your test case should compile.
Comment #3 by ryan — 2014-10-31T18:17:39Z
Confirmed on DMD 2.066.0-1 on Linux. It also fails to catch the error inside an anonymous enum aggregate. If I declare ModuleData as: private enum { ModuleData = "asdfgh" } it also slips by the compiler without error.
Comment #4 by k.hara.pg — 2014-11-01T13:32:34Z
Comment #5 by github-bugzilla — 2014-11-02T01:15:55Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0abc856097f35e0fd4451b28704be03058cc4820 fix Issue 10528 - Private constant (enum) properties not private https://github.com/D-Programming-Language/dmd/commit/22cefcebcb7745e4aa9267f6b42c22bd2d42eca7 Merge pull request #4104 from 9rnsr/fix10528 Issue 10528 - Private constant (enum) properties not private
Comment #6 by github-bugzilla — 2015-02-18T03:39:05Z