This code causes a range violation exception. It goes away if the postblit operator is commented away. The root cause is in the front-end which generates code that gets the element at key zero (to create a temp as argument to opAssign). I was able to work around it in my back-end for .NET, but then the assertion fails, because the front-end does not generate the call to postblit. struct X { int i; this(this) { ++i; } } void main() { X [int] xs; xs[0] = X(); assert(xs[0].i == 1); }
Also happens when opAssign is overloaded: struct Foo { uint stuff; void opAssign(Foo rhs) { stuff = rhs.stuff; } } void main() { Foo[string] AA; AA["bar"] = Foo.init; // Range violation. }
*** This issue has been marked as a duplicate of issue 2451 ***