January 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7236

           Summary: Protected class members in different file inaccessible
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: full.demon@gmail.com


--- Comment #0 from Taco <full.demon@gmail.com> 2012-01-05 14:50:24 PST ---
Example:

a.d:
class A
{
protected:
    void f()
    {
    }
}


main.d:
import a;

class B: A
{
public:
    void g(A a) // using g(B b) it works
    {
        a.f(); // error
    }
}

int main()
{
    auto b = new B;
    b.g(b);
}


dmd main.d a.d

Error: class a.A member f is not accessible


This is ONLY if A is in a different file (else B can access any of A its members due to module accessibility). If g accepts B instead of A it works though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7236


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-19 13:51:25 PDT ---
Confirmed on 2.059

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7236



--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-04-21 01:47:16 PDT ---
I think this is a major bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7236



--- Comment #3 from SomeDude <lovelydear@mailmetrash.com> 2012-04-21 02:28:51 PDT ---
It also works with the following calls: f(), this.f() and super.f()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7236



--- Comment #4 from SomeDude <lovelydear@mailmetrash.com> 2012-04-23 02:22:36 PDT ---
See also on the same topic issue 5769

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 13, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7236


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |andrej.mitrovich@gmail.com
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-13 09:58:51 PST ---
https://github.com/D-Programming-Language/dmd/pull/1478

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7236


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |INVALID


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2013-02-03 16:52:52 PST ---
This is exactly the way it is designed to work. Accessibility is determined by the 'this' pointer, not the function it is in (C++ operates the same way). And, of course, code in a module has all access to other classes in the same module.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7236



--- Comment #7 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-04 11:16:08 PST ---
(In reply to comment #6)
> This is exactly the way it is designed to work. Accessibility is determined by the 'this' pointer, not the function it is in.

Perhaps, but it could be a future enhancement. I'm not sure about the pros vs cons, maybe encapsulation would break under this enhancement. The damage seems limited though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home