www.digitalmars.com         C & C++   DMDScript  

D - Bug: "class B forward reference of base class A"

reply Andy Friesen <andy ikagames.com> writes:
Maybe this has been posted before, but I don't recall anybody managing 
to isolate this into a handful of lines of code, so I may as well post 
it now. (apologies if it has already been posted)

a.d:
	import b;

	class A
	{
	    B[] b;
	}

b.d:
	import a;

	class B : A
	{
	}


D:\temp\dtest>dmd a.d b.d
b.d: class B forward reference of base class A

  -- andy
Jan 19 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Mon, 19 Jan 2004 18:45:19 -0800, Andy Friesen wrote:

 Maybe this has been posted before, but I don't recall anybody managing 
 to isolate this into a handful of lines of code, so I may as well post 
 it now. (apologies if it has already been posted)
 
 a.d:
 	import b;
 
 	class A
 	{
 	    B[] b;
 	}
 
 b.d:
 	import a;
 
 	class B : A
 	{
 	}
 
 
 D:\temp\dtest>dmd a.d b.d
 b.d: class B forward reference of base class A
 
   -- andy

I was going to suggest: ################# module A; class A { private import B; B b; } ################# module B; import A; class B : A { } ################# but that kinda segfaults the compiler (0.78) even if we remove the "module" statments. which if funny because the test I done before works fine: ################# class A { private import std.string; void a() { printf("A.a std.string.toString(1)== %.*s\n",std.string.toString(1)); } } ################# private import ImpA; class B { private import std.string; void b() { printf("B.b std.string.toString(2)== %.*s\n",std.string.toString(2)); } } void main() { B b = new B; b.b(); } ################# Ant
Jan 19 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Mon, 19 Jan 2004 22:08:38 -0500, Ant wrote:

ok forget the second test.
I guess it was to test something else.
I have a directory full of these simple tests...

Ant
Jan 19 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Mon, 19 Jan 2004 22:11:06 -0500, Ant wrote:

 On Mon, 19 Jan 2004 22:08:38 -0500, Ant wrote:
 
 ok forget the second test.
 I guess it was to test something else.
 I have a directory full of these simple tests...
 
 Ant

OK I went back to that second test. If class B : A still compiles which shows the point I was trying to make. if class B : A (again) and remove the import std.string from class B the it still compiles and ouputs "B.b std.string.toString(2)== 2" that shows that the "private" in "private import std.string" inside the body definition of A is not respected in B Ant
Jan 19 2004
parent Lars Ivar Igesund <larsivar igesund.net> writes:
Ant wrote:
 On Mon, 19 Jan 2004 22:11:06 -0500, Ant wrote:
 
 
On Mon, 19 Jan 2004 22:08:38 -0500, Ant wrote:

ok forget the second test.
I guess it was to test something else.
I have a directory full of these simple tests...

Ant

OK I went back to that second test. If class B : A still compiles which shows the point I was trying to make. if class B : A (again) and remove the import std.string from class B the it still compiles and ouputs "B.b std.string.toString(2)== 2" that shows that the "private" in "private import std.string" inside the body definition of A is not respected in B Ant

I also reported on this with minimal examples some time ago. Disrespect of the 'private' keyword for modules seemed to be the main problem. Lars Ivar Igesund
Jan 20 2004