Better error messages - from reddit
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 4 23:48:44 UTC 2019
On Mon, Mar 04, 2019 at 11:03:28PM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Monday, 4 March 2019 at 15:47:12 UTC, H. S. Teoh wrote:
> > This is why I'm starting to think sig constraints are not the genius
> > idea they first appeared to be.
>
> If the implementation actually told you which individual pieces failed
> (and perhaps even why), I don't think we'd be worried about this.
[....]
> Imagine what we'd say if the error message was not:
[...]
> but rather
>
>
>
> ooooo.d(4): Error: template std.algorithm.sorting.sort cannot deduce
> function from argument types
> !()(FilterResult!(unaryFun, int[])), candidates are:
> /home/me/d/dmd2/linux/bin32/../../src/phobos/std/algorithm/sorting.d(1847):
> std.algorithm.sorting.sort([collapsed])(Range r)
> if (
> // passed
> (ss == SwapStrategy.unstable &&
> // passed
> (hasSwappableElements!Range || hasAssignableElements!Range) ||
> // short-circuited
> ss != SwapStrategy.unstable &&
> asAssignableElements!Range)
> // ******* FAILED ***********
> && isRandomAccessRange!Range
> // short-circuited, but would fail
> && hasSlicing!Range && hasLength!Range
> )
>
>
> That tells you everything you need to know.
Yes, this is indeed a big improvement over what we currently have. It
may not be perfect, but it goes a long way from where we are right now.
Also, it should be relatively straightforward to implement, and doesn't
break any existing code, etc..
Where's the PR for this??? I want it NAO! :-D
T
--
A mathematician is a device for turning coffee into theorems. -- P. Erdos
More information about the Digitalmars-d
mailing list