April 07, 2005
Hello,

We have discovered a possible bug which does not allow access of private  declared members in the same module when using template classes.

In the next example the class "Baz" works fine. If we take the same thing however, and make a template class of it "Bar", the compiler fails to compile, complaining about Bar.doSomething() being private.

According to the D-specs it should be accessible in the same module?

<code>
class Bar(Type)
{
    this()
    {
    }

    private void doSomething()
    {
    }
}

class Baz
{
    this()
    {
    }

    private void doSomething()
    {
    }
}

void main()
{
    //this is ok
    Baz a = new Baz();
    a.doSomething();

    //this fails
    Bar!(int) b = new Bar!(int)();
    b.doSomething();
}
</code>

The original post about this was in digitalmars.D.learn under
"Templates + protection attributes problem"
(news://news.digitalmars.com:119/d31ndi$amo$1@digitaldaemon.com)
April 08, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin VR schrieb am Fri, 08 Apr 2005 00:25:31 +0200:
> Hello,
>
> We have discovered a possible bug which does not allow access of private
>   declared members in the same module when using template classes.
>
> In the next example the class "Baz" works fine. If we take the same thing however, and make a template class of it "Bar", the compiler fails to compile, complaining about Bar.doSomething() being private.
>
> According to the D-specs it should be accessible in the same module?
>
><code>
> class Bar(Type)
> {
>      this()
>      {
>      }
>
>      private void doSomething()
>      {
>      }
> }
>
> class Baz
> {
>      this()
>      {
>      }
>
>      private void doSomething()
>      {
>      }
> }
>
> void main()
> {
>      //this is ok
>      Baz a = new Baz();
>      a.doSomething();
>
>      //this fails
>      Bar!(int) b = new Bar!(int)();
>      b.doSomething();
> }
></code>
>
> The original post about this was in digitalmars.D.learn under "Templates + protection attributes problem" (news://news.digitalmars.com:119/d31ndi$amo$1@digitaldaemon.com)

Added to DStress as http://dstress.kuehne.cn/run/private_04.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCVhsr3w+/yD4P9tIRAgu5AJ9jh5pME056e0RdoYuAPF6w3CtSVACggLNM
lNBBJ9i78kTvE+61u5m9p7E=
=8Cr2
-----END PGP SIGNATURE-----