www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - name resolution and static function

reply Carlos Santander <csantander619 gmail.com> writes:
I'm sure this also has to do with how name resolution works, but here it is
anyway:

//---------------------------------
class A
{
         void foo () {}
         //private
         static void foo (int i) {}
}

class B
{
         void foo (int x)
         {
                 A.foo (x);
         }
}
//---------------------------------

I get:
test.d:12: 'this' is required, but test.A is not a base class of B

And if I uncomment the private attribute in A, I get:
test.d:12: 'this' is required, but test.A is not a base class of B
test.d:12: class test.B member foo is not accessible

gdc rev 13 (DMD 0.162)

-- 
Carlos Santander Bernal
Jul 09 2006
next sibling parent reply Derek Parnell <derek nomail.afraid.org> writes:
On Sun, 09 Jul 2006 21:25:27 -0500, Carlos Santander wrote:

 I'm sure this also has to do with how name resolution works, but here it is
anyway:
 
 //---------------------------------
 class A
 {
          void foo () {}
          //private
          static void foo (int i) {}
 }
 
 class B
 {
          void foo (int x)
          {
                  A.foo (x);
          }
 }
 //---------------------------------
 
 I get:
 test.d:12: 'this' is required, but test.A is not a base class of B
 
 And if I uncomment the private attribute in A, I get:
 test.d:12: 'this' is required, but test.A is not a base class of B
 test.d:12: class test.B member foo is not accessible
 
 gdc rev 13 (DMD 0.162)

Seems to be a bug. If you place the 'static' one first it compiles fine. class A { // private static void foo (int i) {} void foo () {} } -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocrity!" 10/07/2006 1:53:10 PM
Jul 09 2006
parent Walter Bright <newshound digitalmars.com> writes:
Derek Parnell wrote:
 Seems to be a bug. If you place the 'static' one first it compiles fine.

Yes, it's a bug.
Jul 12 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carlos Santander schrieb am 2006-07-10:
 I'm sure this also has to do with how name resolution works, but here it is
anyway:

 //---------------------------------
 class A
 {
          void foo () {}
          //private
          static void foo (int i) {}
 }

 class B
 {
          void foo (int x)
          {
                  A.foo (x);
          }
 }
 //---------------------------------

 I get:
 test.d:12: 'this' is required, but test.A is not a base class of B

 And if I uncomment the private attribute in A, I get:
 test.d:12: 'this' is required, but test.A is not a base class of B
 test.d:12: class test.B member foo is not accessible

 gdc rev 13 (DMD 0.162)

Added to DStress as http://dstress.kuehne.cn/run/s/static_37_A.d http://dstress.kuehne.cn/run/s/static_37_B.d http://dstress.kuehne.cn/run/s/static_37_C.d http://dstress.kuehne.cn/run/s/static_37_D.d http://dstress.kuehne.cn/run/s/static_37_E.d http://dstress.kuehne.cn/run/s/static_37_F.d http://dstress.kuehne.cn/run/s/static_37_G.d http://dstress.kuehne.cn/run/s/static_37_H.d http://dstress.kuehne.cn/run/s/static_37_I.d http://dstress.kuehne.cn/run/s/static_37_J.d http://dstress.kuehne.cn/run/s/static_37_K.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFCQNrLK5blCcjpWoRAsVKAJ9ztvH0HR1InPxrlLf0HoqRQuNXjwCeLKc2 Q7WTSryFA5zzjs3FhGzszTc= =aAdL -----END PGP SIGNATURE-----
Sep 14 2006