www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [D1, module, type conflict] Which bug is this?

reply %u <e ee.com> writes:
The code below results in:

i.d(7): Error: a.B at a.d(2) conflicts with c.B at c.d(4)

changing main to only import i results in:

b.d(4): Error: struct b.B unable to resolve forward reference in definition
a.d(4): Error: struct a.A unable to resolve forward reference in definition
repeated 5 times

--
module main;
import c;

void main(){}
--
module a;
import b : B;

struct A {
  B b;
}
--
module b;
import a : A;

struct B{
  A a;
}
--
module i;
import a;
import b;
import c;

interface I{
  B fb();
}
--
module c;
import i : I;
import a : A;
import b : B;

class C : I{
  this(){}
  B fb(){
    B b;
    return b;
  }
}
--
Nov 01 2010
parent %u <e ee.com> writes:
Disregard that, here is the real bug. I removed the circular struct definition.

The code below results in:
i.d(7): Error: b.B at b.d(5) conflicts with c.B at c.d(3)

But if the selective imports are changed to non-selective public imports(
bug[314]
) the error is gone.

--
module main;
import c;

void main(){}
--
module c;
import i;
import b : B;
//public import b;

class C : I{
  this(){}
  B fb(){
    B b;
    return b;
  }
}
--
module i;

import b;
import c;

interface I{
  B fb();
}
--
module b;
import a : A;
//public import a;

struct B{
  A a;
}
--
Nov 01 2010