class C { immutable int x; this() { this.f(this.x = 5); } void f(lazy int x){} } C.int isn't initialized, although this code compiles. Whether C.int is initialized or not depends on the, in general indeterministic, behavior of f(), this should be a compile time error.
I think this is part of a bigger problem: ---------------------------------------- class A { immutable int x; void delegate() f; this() { x = 40; f = () { x = 42; }; } } void main() { import std.stdio; auto a = new A(); writeln(a.x); a.f(); writeln(a.x); } ---------------------------------------- 40 42
The root is that delegate construction does not respect immutability at all. struct S { void foo() immutable {} void baz() { //foo(); (&foo)(); } }
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18619 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB