https://issues.dlang.org/show_bug.cgi?id=13683

--- Comment #5 from Nick Treleaven <[email protected]> ---
static assert is an improvement over the constraint, but it still hides the
actual error message which should be:

Error: use `!is` instead of `!=` when comparing with `null`

Removing the constraint allows the correct error to be seen. But then the
constraint may be needed to disambiguate overloads. Without a compiler
solution,  we could have a new trait - __traits(canPass, pred, range.front)
which ignores the body of pred:

https://forum.dlang.org/post/[email protected]

In the absence of that, the best I've come up with is:

if (__traits(isTemplate, pred) || is(typeof(pred(range.front))))

Which doesn't check that pred can take that argument when pred is a lambda, but
it doesn't hide the actual error unlike the constraint status quo or the static
assert way.

A compiler solution might not work in the presence of overloads, because
currently failing constraints are only shown when there are no overloads.

--

Reply via email to