www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Private bug

reply bobef <bobef lessequal.com> writes:
------- a.d

import b;
void main(){a("asd");}

------- b.d

private void a(int s,int r){};
public void a(char[] s){};

------- dmd a.d

a.d: module a b.a is private
Feb 11 2006
next sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"bobef" <bobef lessequal.com> wrote in message 
news:dsk9hb$ugh$1 digitaldaemon.com...
 ------- a.d

 import b;
 void main(){a("asd");}

 ------- b.d

 private void a(int s,int r){};
 public void a(char[] s){};

 ------- dmd a.d

 a.d: module a b.a is private
I think this is what's happening: 1) The overload mechanism works just fine for functions of different protection attributes. 2) When compiling a.d, it checks for overloads in b.d, going definition by definition. It also checks if the calling scope can access the functions. 3) It comes across the private overload first, and throws an error since a.d can't access private members of b.d. I'd say this is a bug, but in the meantime, just define the public overload before the private one. Then DMD comes across that one first when checking overloads, and it works.
Feb 11 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bobef schrieb am 2006-02-11:
 ------- a.d

 import b;
 void main(){a("asd");}

 ------- b.d

 private void a(int s,int r){};
 public void a(char[] s){};

 ------- dmd a.d

 a.d: module a b.a is private
Added to DStress as http://dstress.kuehne.cn/run/p/private_10_A.d http://dstress.kuehne.cn/run/p/private_10_B.d http://dstress.kuehne.cn/run/p/private_10_C.d http://dstress.kuehne.cn/run/p/private_10_D.d http://dstress.kuehne.cn/nocompile/p/private_10_E.d http://dstress.kuehne.cn/nocompile/p/private_10_F.d http://dstress.kuehne.cn/nocompile/p/private_10_G.d http://dstress.kuehne.cn/nocompile/p/private_10_H.d http://dstress.kuehne.cn/addon/private_10_Z.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD7h8M3w+/yD4P9tIRAkv4AJoDN/BxCCS7U1pXa6tQcMzsYz9nngCfXFWx H0h+xomRng67EYuwQp3gxBA= =fe+r -----END PGP SIGNATURE-----
Feb 11 2006