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?