Bug? package attribute half working on child packages.

Daniel Keep daniel.keep.lists at gmail.com
Sun Mar 15 16:53:01 PDT 2009



Jarrett Billingsley wrote:
> On Sun, Mar 15, 2009 at 5:55 PM, Jeremie Pelletier <jeremiep at gmail.com> wrote:
>> I don't know if it's really a bug, but the package protection attribute seems to have a different semantic in the current packages than in nested packages.
>>
>> For example, say you have the module test which declares the following:
>> ---
>> module test.Foo;
>>
>> package uint myVar;
>> package class MyClass {}
>>
>> package void MyFunc();
>>
>> class Foo {
>>    package void MyFoo();
>> }
>> ---
>>
>> All declarations are accessible from any module in the test package, but if you try and access them from a child package, say test.somepackage.Foo, then only myVar and MyClass are accessible, both MyFunc and Foo.MyFoo says they aren't accessible from test.somepackage.Foo.
>>
>> I'm using the latest DMD version 2.
>>
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=2529
> 
> Feel free to comment or vote.

A quick poke in the source code reveals a hasPackageAccess function in
access.c.  Haven't tried this, but maybe the attached patch (made
against the 1.041 release) will get the desired behaviour; I just
quickly changed it to search not just the scope's package, but also its
ancestors.

  -- Daniel


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: subpackage_access.diff
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20090316/835257fd/attachment.ksh>


More information about the Digitalmars-d mailing list