Better error messages - from reddit

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Mar 5 00:44:25 UTC 2019


On Tuesday, 5 March 2019 at 00:03:39 UTC, H. S. Teoh wrote:
> On Mon, Mar 04, 2019 at 11:54:34PM +0000, Adam D. Ruppe via 
> Digitalmars-d wrote:
>> On Monday, 4 March 2019 at 23:46:55 UTC, Nicholas Wilson wrote:
>> > https://github.com/dlang/DIPs/pull/131
>> 
>> Seems overkill to me, though it might be useful in some cases, 
>> the compiler already has enough information in current code. 
>> It just isn't telling us what it knows.
>> 
>> (that said i prolly wouldn't vote against it, i also don't see 
>> a need to change code to improve error messages.)
>
> Yeah, I think the DIP would be a welcome improvement, but OTOH 
> Adam's idea already works without needing to change existing 
> code, because the compiler already knows what it knows.

You still need to change the compiler, which is very hard because 
...

> Given that programmers tend to be lazy (why spend the time 
> writing elaborate sig constraints when I could be working on 
> the function body where the real work is done), having the 
> compiler able to emit useful information *without help from the 
> programmer* is a big plus.
>
> An even bigger plus is that it can be done today with just a 
> little change in the compiler.

... the problem (from the perspective of issuing a nice error) is 
that you can arbitrarily compose logic which makes sorting the 
what from the chaff extremely difficult and that signal to noise 
is very important (ever used -verrors=spec ?). Believe me I 
tried, saw a suggestion by aliak in a Phobos PR thread and 
thought that would make things so much easier, and thus arose 
that DIP.

The DIP also allows you to give a message if a particular 
subcontract failed. IMO they are much easier to look at (no need 
to match parens and keep track of && and ||'s .



More information about the Digitalmars-d mailing list