Thread overview
Bug: "class B forward reference of base class A"
Jan 20, 2004
Andy Friesen
Jan 20, 2004
Ant
Jan 20, 2004
Ant
Jan 20, 2004
Ant
Jan 20, 2004
Lars Ivar Igesund
January 20, 2004
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
January 20, 2004
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

January 20, 2004
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
January 20, 2004
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

January 20, 2004
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