Better error messages - from reddit
Nicholas Wilson
iamthewilsonator at hotmail.com
Tue Mar 5 01:23:58 UTC 2019
On Tuesday, 5 March 2019 at 01:07:08 UTC, Walter Bright wrote:
> Use of `static if` and `pragma(msg)` can be used to generate
> custom error messages:
>
> static if (!isInputRange(r)) pragma(msg, r, " must be an
> Input Range");
That doesn't work if you need to overload against it because then
you will cause a matches multiple template error.
> This is ultimately far more powerful than anything the compiler
> can come up with, because it can be about the user's context,
> not the compiler's.
That power and flexibility does however severely limit the
compiler's ability to provide sensible error messages, 99.9% of
constraints are in CNF because thats the only reasonable way to
compose and perform overload specialisation.
The DIP covers all the cases.
More information about the Digitalmars-d
mailing list