[Issue 2225] New: accessing private declaration allowed
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Jul 13 20:50:13 PDT 2008
<d-bugmail at puremagic.com> wrote in message
news:bug-2225-3 at 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 at digitalmars.com
> ReportedBy: davidl at 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.
More information about the Digitalmars-d-bugs
mailing list