Le 18/06/2012 07:36, Mehrdad a écrit :
Is it just me, or did I subvert the type system here?
delegate fail to ensure transitivity of type qualifier. This is no news. This is however a big error.
I proposed a fix to that by changing the semantic of the type qualifier depending on its position in the declaration, but didn't received much feedback at the time.
import std.stdio; struct Const { this(void delegate() increment) { this.increment = increment; } int a; void delegate() increment; void oops() const { this.increment(); } } void main() { Const c; c = Const({ c.a++; }); writeln(c.a); c.oops(); writeln(c.a); }