Immutable & circular imports
Tomek Sowiński
just at ask.me
Wed Dec 16 15:15:30 PST 2009
Amusing things happen when immutable arguments and circular imports are
put together:
----------------------------------------------
module hello;
import test;
struct Strukt {
Staly* s;
}
----------------------------------------------
module test;
import hello;
immutable struct Staly {
int a;
}
void f_strukt(Strukt* stk) {
f_staly(stk.s); // ups!
}
void f_staly(Staly* s) { }
----------------------------------------------
Error: function test.f_staly (immutable(Staly)* s) is not callable using
argument types (Staly*)
Error: cannot implicitly convert expression ((*stk).s) of type Staly* to
immutable(Staly)*
Am I writing code too weird or is this a compiler bug? The only thing
about circular imports on D page is: "Cycles (circular dependencies) in
the import declarations are allowed as long as not both of the modules
contain static constructors or static destructors." So what I tried to
pull off seems fair game.
Tomek
More information about the Digitalmars-d-learn
mailing list