www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11234] New: Method of another module is callable, even if they is private.

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

           Summary: Method of another module is callable, even if they is
                    private.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rswhite4 googlemail.com



A.d:
----
import B;

class Foo {
public:
    void call(Bar b) {
        void delegate(int) dg = &b.test;
        dg(42);
    }
}

void main() {
    Bar b = new Bar();
    Foo f = new Foo();
    f.call(b);
}
----

B.d:
----
import std.stdio;

class Bar {
private:
    void test(int id) {
        writeln("Bar called with ", id);
    }
}
----

Output: Bar called with 42
But should be rejected.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |andrej.mitrovich gmail.com
            Summary|Method of another module is |Address of private method
                   |callable, even if they is   |from another module can be
                   |private.                    |taken



12:23:34 PDT ---
Reduced a little bit:

-----
module a;
import b;

void main()
{
    auto s = S();
    auto f = &s.f;  // no error
    f();  // no error

    auto sf = &S.sf;  // error
}
-----

-----
module b;
struct S
{
    private void f() { }
    private static void sf() { }
}
-----

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




I'm unsure, but maybe we should also classify this as major because it breaks
the protection?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2013