Error: cannot deduce function from argument types

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


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 

Error: template std.string.stripRight cannot deduce function from 
argument types !()(string, string), candidates are:
    std.string.stripRight(Range)(Range str) if (isSomeString!Range 
|| isRandomAccessRange!Range && hasLength!Range && 
hasSlicing!Range && !isConvertibleToString!Range && 
    std.string.stripRight(Range)(auto ref Range str) if 
ldmd2 failed with exit code 1.


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,

More information about the Digitalmars-d-learn mailing list