What is this error message telling me?
Anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 11 07:51:44 PDT 2017
I was watching a dconf presentation from last year and wanted to
try this out: https://github.com/luismarques/parnas72. It doesn't
compile / run as it is and the problem seems to be in the
function below.
import std.algorithm;
import std.range;
import std.uni;
/// Performs [["foo", "bar"], ["baz"]] -> ["baz", "foo bar"]
auto alphabetized(Range)(Range range)
{
return range
.map!(line => line.joiner(" "))
.array
.sort!((a, b) => icmp(a, b) < 0);
}
void main()
{
auto a = alphabetized([["foo", "bar"], ["baz"]]);
}
More specifically, icmp doesn't seem to be allowed as the
predicate for sort:
Here's the error message I get:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\uni.d(7082): Error:
function 'std.algorithm.searching.skipOver!(Result,
dstring).skipOver' is not nothrow
C:\D\dmd2\windows\bin\..\..\src\phobos\std\uni.d(7055): Error:
nothrow function 'std.uni.fullCasedCmp!(Result).fullCasedCmp' may
throw
C:\D\dmd2\windows\bin\..\..\src\phobos\std\uni.d(7136): Error:
template instance std.uni.fullCasedCmp!(Result) error
instantiating
test.d(14): instantiated from here: icmp!(Result, Result)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\sorting.d(1851): instantiated from here: __lambda3!(Result, Result)
test.d(14): instantiated from here: sort!((a, b) =>
icmp(a, b) < 0, cast(SwapStrategy)0, Result[])
test.d(19): instantiated from here:
alphabetized!(string[][])
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\sorting.d(1863): Error: static assert "Invalid predicate passed to sort: __lambda3"
test.d(14): instantiated from here: sort!((a, b) =>
icmp(a, b) < 0, cast(SwapStrategy)0, Result[])
test.d(19): instantiated from here:
alphabetized!(string[][])
My question is, how do I begin to understand error messages like
the above? I looked at the signature for sort and icmp and don't
get what the problem is.
Thanks.
More information about the Digitalmars-d-learn
mailing list