http://d.puremagic.com/issues/show_bug.cgi?id=6695
--- Comment #7 from luka8088 <luka8...@owave.net> 2011-09-20 10:59:37 PDT --- (In reply to comment #6) > (In reply to comment #5) > > so this is a bug or not ... ? > > > > // Error: function b.c () is not callable using argument types () immutable > > > > import std.stdio; > > > > immutable struct a { > > b b1; > > } > > > > struct b { > > void c () { } > > } > > > > void main () { > > a a1; > > a1.b1.c(); > > } > > Not a bug. Inside the c function, 'this' is mutable, and you are trying to > pass an immutable struct as the 'this' parameter. Immutable cannot implicitly > cast to mutable, so it fails to compile. > > You should read up on the spec documentation about const and immutable, it > will > help to understand it. I agree that maybe this is not a bug, but I don't agree with the explanation ... Documentation says "Both immutable and const are transitive, which means that any data reachable through an immutable reference is also immutable, and likewise for const." So in this example: import std.stdio; immutable struct a { b b1; } struct b { immutable void c () { } void d () { } immutable int e ; int f ; } void main () { a a1; b b1; writeln(" b1.c ", typeid(typeof(b1.c))); // immutable(void()) writeln(" b1.d ", typeid(typeof(b1.d))); // void() writeln(" b1.e ", typeid(typeof(b1.e))); // immutable(int) writeln(" b1.f ", typeid(typeof(b1.f))); // int writeln("a1.b1.c ", typeid(typeof(a1.b1.c))); // immutable(void()) writeln("a1.b1.d ", typeid(typeof(a1.b1.d))); // void() writeln("a1.b1.e ", typeid(typeof(a1.b1.e))); // immutable(int) writeln("a1.b1.f ", typeid(typeof(a1.b1.f))); // immutable(int) } >From the documentation, both typeid(typeof(a1.b1.d)) and typeid(typeof(a1.b1.f)) should be either mutable or immutable, right ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------