Immutable & circular imports
grauzone
none at example.net
Wed Dec 16 16:14:53 PST 2009
Tomek Sowiński wrote:
> 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.
There are a _lot_ of circular dependency bugs, and there are a lot of
immutable related bugs. Combine both together and you get... probably
even more bugs.
>
> Tomek
More information about the Digitalmars-d-learn
mailing list