www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9381] New: package access can be abused and worked around

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9381

           Summary: package access can be abused and worked around
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



18:05:26 PST ---
/a/m.d:
module a.m;
package void foo() { }

/user/a/workaround.d:
module a.workaround;
import a.m;
auto foo()
{
    return a.m.foo();  // free access!
}

/user/main.d:
module main;
import a.workaround;
void main()
{
    foo();
}

$ rdmd user/main.d

No compile errors!

Even though user/a/workaround is *not* part of the library defined in the 'a'
folder, it has free access to all package 'a' modules.

Package should probably be checked on a folder level and not just on a module
declaration level to make it useful.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9381




18:07:47 PST ---

 Package should probably be checked on a folder level and not just on a module
 declaration level to make it useful.
Although if a library writer has e.g. 'foo/bar' package split around multiple directories and is using import switches, then this would break his code. So this could end up being a stale-mate, unless we re-design access modifiers altogether (a DIP was already called for by Walter). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 23 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9381


Oleg Kuporosov <Oleg.Kuporosov gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Oleg.Kuporosov gmail.com



03:47:44 PST ---
Isn't a dup of http://d.puremagic.com/issues/show_bug.cgi?id=143 ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9381




06:39:03 PST ---

 Isn't a dup of http://d.puremagic.com/issues/show_bug.cgi?id=143 ?
No, that's related to package not working on variables. It works on functions, but as the sample shows it can be easily worked around. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 24 2013