On 06/18/2012 04:55 PM, Mehrdad wrote:

Identical calls giving identical results? What?


import std.stdio;
struct S
{
          this(int a)
          {
                  this.a = a;
                  this.increment = { return this.a++; };
          }
          int a;
          int delegate() pure increment;
          auto oops() const { return this.increment(); }
}
void main()
{
          auto c = immutable(S)(0);
          writeln(c.oops()); // 0
          writeln(c.oops()); // 1
          writeln(c.oops()); // 2
          writeln(c.oops()); // 3
          writeln(c.oops()); // 4
          writeln(c.oops()); // 5
}

Now you have managed to break the type system.
The underlying issue is unrelated to delegates though.

Reply via email to