Casting between delegates with qualified value type parameters

2011-01-20 Thread Sean Eskapp
Delegates cannot be cast from one type to another, even if the only difference
in type is the qualifiers on value type parameters. However, the same code
works fine with functions instead of delegates, as such:

import std.stdio;

void foo(void function(int) bar)
{
bar(5);
}

void foobar(void delegate(int) bar)
{
bar(5);
}

void main()
{
foo   (function(int i)   { writeln(i); }); // OK
foo   (function(immutable int i) { writeln(i); }); // OK
foobar(delegate(int i)   { writeln(i); }); // OK
foobar(delegate(immutable int i) { writeln(i); }); // error
}


Is there a reason for this, or is it a bug?


Re: Casting between delegates with qualified value type parameters

2011-01-23 Thread Daniel Murphy
"Sean Eskapp"  wrote in message 
news:ih9rhr$2c1k$1...@digitalmars.com...
>
> Is there a reason for this, or is it a bug?

Sounds like it could be http://d.puremagic.com/issues/show_bug.cgi?id=3797

All sorts of implicit conversions are currently allowed between function 
pointers that shouldn't be.