main() { alias int delegate( const int[] ) A; alias int delegate( int[] ) B; A a; B b = cast(B) a; // OK B b2 = a; // Error: cannot implicitly convert expression (a) of type // int delegate(const(int[])) to int delegate(int[]) } I think the cast is unnecessary, (b) should be allowed to point to a delegate of type (A) as well.
I think you might have this around the wrong way...
void main() { alias int delegate( const int[] ) A; alias int delegate( int[] ) B; int c_func( const int[] arg ) { return arg[0]; } int m_func( int[] arg ) { return arg[0] = 0; } const int[] ci = [ 1,2,3 ]; int[] mi = [ 4,5,6 ]; A a = &c_func; a( ci ); a( mi ); B b = &m_func; // b( ci ); Error ( good ) b( mi ); /* b = &c_func; Error: cannot implicitly convert expression (&c_func) of type int delegate(const(int[])) to int delegate( int[] ) */ b = cast(B) &c_func; // Forced to cast // Even though b really points to c_func; // It has to be a type error to attempt it // b( ci ); Error ( good ) b( mi ); } if b() can point to a function that mutates it's argument why can't it point to a function that does not mutate it's argument?
*** This issue has been marked as a duplicate of issue 3075 ***