https://issues.dlang.org/show_bug.cgi?id=5207
--- Comment #8 from RazvanN <[email protected]> --- (In reply to hsteoh from comment #7) > Here's an example of a problematic case: In the code that you have posted there seems to be an error with regards to module constructors, because if you put the same code in a normal constructor: import std; struct S { int x; this(int k) { fun(&s); writeln(ptr.x); // prints 0 s.x = 1; writeln(ptr.x); // prints 1 s.x = 2; writeln(ptr.x); // prints 2: immutability broken } } immutable S s; immutable(S)* ptr; void fun(immutable(S)* p) { ptr = p; } you will get errors when trying to modify `s`. The bug in the example that you posted is that `s` is not typechecked correctly in the module constructor, not the fact that you should not be able to read an immutable variable before initialization. --
