Thread overview | |||||
---|---|---|---|---|---|
|
February 11, 2006 Private bug | ||||
---|---|---|---|---|
| ||||
------- 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 |
February 11, 2006 Re: Private bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | "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. |
February 11, 2006 Re: Private bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef Attachments: | 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 |
Copyright © 1999-2021 by the D Language Foundation