www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Intended behavior or bug (private vs public static)

reply "Andre" <andre s-e-a-p.de> writes:
Hi,

following code fails with errors:
class test.A member b is not accessible

I am not sure, whether it should work or not?

Kind regards
André

module app;
import test;

void main()
{
	A.b("");
}

module test;

class A
{
	private void b(){}
	static void b(string b){}
}
Nov 06 2014
parent reply Jonathan M Davis via Digitalmars-d-learn writes:
On Friday, November 07, 2014 05:43:28 Andre via Digitalmars-d-learn wrote:
 Hi,

 following code fails with errors:
 class test.A member b is not accessible

 I am not sure, whether it should work or not?

 Kind regards
 André

 module app;
 import test;

 void main()
 {
   A.b("");
 }

 module test;

 class A
 {
   private void b(){}
   static void b(string b){}
 }
That looks like a bug. All you have to do is change the order of the two function declarations or rename the non-static one to something else, and it compiles. So, somehow, the fact that the non-static one has the same name as the static one and the fact that it comes first screws up accessing the static one. And explicitly marking the static one as public doesn't help. So, you should report is a compiler bug: https://issues.dlang.org - Jonathan M Davis
Nov 06 2014
parent "Andre" <andre s-e-a-p.de> writes:
Thanks a lot. I will create a bug report.

Kind regards
André


On Friday, 7 November 2014 at 06:09:02 UTC, Jonathan M Davis via 
Digitalmars-d-learn wrote:

 That looks like a bug. All you have to do is change the order 
 of the two
 function declarations or rename the non-static one to something 
 else, and it
 compiles. So, somehow, the fact that the non-static one has the 
 same name as
 the static one and the fact that it comes first screws up 
 accessing the
 static one. And explicitly marking the static one as public 
 doesn't help.
 So, you should report is a compiler bug:

 https://issues.dlang.org

 - Jonathan M Davis
Nov 07 2014