digitalmars.D.bugs - [Issue 2225] New: accessing private declaration allowed
- d-bugmail puremagic.com (38/38) Jul 13 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2225
- Jarrett Billingsley (8/45) Jul 13 2008 So, what's the bug?
http://d.puremagic.com/issues/show_bug.cgi?id=2225 Summary: accessing private declaration allowed Product: D Version: 1.031 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: davidl 126.com a.d module a; import b; int bar() { Outer o = new Outer; o.a = 3; Outer.Inner oi = o.new Inner; return oi.foo(); // returns 3 } b.d module b; class Outer { int a; private: class Inner { int foo() { return a; } } } --
Jul 13 2008
<d-bugmail puremagic.com> wrote in message news:bug-2225-3 http.d.puremagic.com/issues/...http://d.puremagic.com/issues/show_bug.cgi?id=2225 Summary: accessing private declaration allowed Product: D Version: 1.031 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: davidl 126.com a.d module a; import b; int bar() { Outer o = new Outer; o.a = 3; Outer.Inner oi = o.new Inner; return oi.foo(); // returns 3 } b.d module b; class Outer { int a; private: class Inner { int foo() { return a; } } }So, what's the bug? The language has never prevented you from accessing private classes/structs. I don't think it's ever mentioned in the spec. I will, however agree that it _should_ error on this (cannot access private class Inner), making this an enhancement request. If you're expecting foo() to be private, I don't think that's how it works.
Jul 13 2008