Error: cannot deduce function from argument types

Sisor smietzner at yahoo.de
Sat May 5 16:42:12 UTC 2018


Hi,

I have a function:

string strippedString(ubyte[] block) {
	return (cast(string)block).stripRight("\0");
}

With dmd it compiles, with ldc it produces the following error 
message:

Error: template std.string.stripRight cannot deduce function from 
argument types !()(string, string), candidates are:
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/string.d(2902,6):     
    std.string.stripRight(Range)(Range str) if (isSomeString!Range 
|| isRandomAccessRange!Range && hasLength!Range && 
hasSlicing!Range && !isConvertibleToString!Range && 
isSomeChar!(ElementEncodingType!Range))
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/string.d(3015,6):     
    std.string.stripRight(Range)(auto ref Range str) if 
(isConvertibleToString!Range)
ldmd2 failed with exit code 1.

Why?

The modified function does not even compile with either compiler:

string strippedString(ubyte[] block) {
	return cast(string)( block.stripRight(0) );
}

How can I make the function more specific, so that the compiler 
knows, which option to take?

Kind regards,
Sisor


More information about the Digitalmars-d-learn mailing list