I have this function
private ulong Html(ubyte[] data)
{
return data.length;
}
that I want to convert to delegate by using toDelegate() function. I have tried it:
client.onReceive = toDelegate(&Html);
But I’m getting an error message:
lixo.d(722): Error: not a property client.onReceive
/home/$/D/libs/arsd/dom.d(743): Warning: statement is not reachable
/usr/include/d/dmd/phobos/std/range.d(595): Error: static assert "Cannot put a dchar[] into a Appender!(char[])"
/usr/include/d/dmd/phobos/std/format.d(1758): instantiated from here: put!(Appender!(char[]),dchar[])
/usr/include/d/dmd/phobos/std/format.d(1514): instantiated from here: formatRange!(Appender!(char[]),dchar[],char)
/usr/include/d/dmd/phobos/std/conv.d(101): instantiated from here: formatValue!(Appender!(char[]),dchar[],char)
/usr/include/d/dmd/phobos/std/conv.d(757): ... (1 instantiations, -v to show) ...
/usr/include/d/dmd/phobos/std/conv.d(244): instantiated from here: toImpl!(char[],dchar[])
/home/$/libs/arsd/dom.d(2115): instantiated from here: to!(dchar[])
How to fix this?
I guess the /home/$/D/libs/arsd/dom.d library has a struct or class called ‘Html‘. Try renaming your ‘Html‘ function to something else and see if it helps.
If it still doesn’t work you probably have to show us more code as your example seems to work fine for me:
http://dpaste.dzfl.pl/fd729f3d
(I’ve seen similar errors before. For some reason the “not a property” error occurs a lot since dmd 2.060 even if the real error is not related.)