Wrong implicit delegate conversion?

Manfred Nowak svv1999 at hotmail.com
Fri Feb 23 15:48:11 PST 2007


Here a delegate from class C seems to be implicitely converted to a 
delegate of the module.

import std.stdio;
alias void delegate( int , inout int) GETTER;
class C{
  int i=3;
  GETTER getter(){
    return delegate void(int i, inout int o){ o= 2*this.i;};
  }
 }
void main(){
  auto c= new C;
  int i=0;
  c.getter()(0,i);
  writefln( i); //works: outputs 6
  GETTER q= c.getter(); // implicit conversion?
  q(0, i);
  writefln( i); //random result
}

-manfred


More information about the Digitalmars-d-bugs mailing list