On Friday, 9 November 2012 at 14:29:06 UTC, Maxim Fomin wrote:
Error: function hello.S.__postblit () is not callable using argument types ()
Error: *&this is not mutable
Error: this is not mutable
Error: this is not mutable
hello.d(6): Error: template instance object.AssociativeArray!(string,const(S)) error instantiating

Making postblit accept const this makes dmd happy.

Seems to be caused by S[S[string]] which requires "this" to be const.

I'm using (DMD64 D Compiler v2.061) and don't see it, so it seems moving from v2.060 to v2.061 takes away some useful error messages which is bad.

I don't think making postblit accept const works - did it for you? If you just mean "this(const this)" it does make it compile - but that postblit is not called.

For example, in code below nothing is printed. Maybe there is a better signature - what did you use? Make postblit this(this) and it is printed. Back to the other example - it seems only this(this) is ever recognized and having this(this) is a problem with associative arrays.

Here is a related thread which in my mind is not resolved.

http://forum.dlang.org/thread/[email protected]#post-jonkbhtibdxjfjethtuo:40forum.dlang.org

Thanks
Dan

import std.stdio;
struct S {
  this(const this) { writeln("Is this called"); }
}

void main() {
  S x;
  const(S) cx;
  S x2 = x;
  S x3 = cx;
}

Reply via email to