My late christmas present for you: context-aware assertion error messages

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jan 14 21:14:14 UTC 2019


On 1/12/19 10:34 AM, Seb wrote:
> tl;dr: I was annoyed for years that D's assert are so non informative 
> AssertError, so here's my late Christmas present for the D community. 
> With 2.085 DMD will gain an experimental flag for more informative 
> assertion errors. Feedback on this experimental feature is welcome, s.t. 
> we eventually can enable it by default.
> 
> Example:
> 
> ---
> void main()
> {
>      int a = 1, b = 2;
>      assert(a == b); // ERROR: 1 != 2
> }
> ---
> 
> ```
>> dmd -run onlineapp.d
> core.exception.AssertError at onlineapp.d(4): 1 != 2

Wonderful. Thanks!



More information about the Digitalmars-d mailing list