Thread overview | |||||
---|---|---|---|---|---|
|
December 16, 2009 Immutable & circular imports | ||||
---|---|---|---|---|
| ||||
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 |
December 17, 2009 Re: Immutable & circular imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomek Sowiński | 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 |
December 17, 2009 Re: Immutable & circular imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to grauzone | Dnia 17-12-2009 o 01:14:53 grauzone <none@example.net> napisał(a): > 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. So I'm noticing... BTW, what is your approach to avoid such woes when writing in D2? Best I could think of so far is putting /*immutable*/, /*pure*/, etc. and relying on "mind compiling" and discipline... which is little fun. Anyway, thanks for reply. I filed a bug. http://d.puremagic.com/issues/show_bug.cgi?id=3629 Tomek |
Copyright © 1999-2021 by the D Language Foundation