My late christmas present for you: context-aware assertion error messages
Atila Neves
atila.neves at gmail.com
Mon Jan 14 14:15:45 UTC 2019
On Saturday, 12 January 2019 at 15:34:02 UTC, 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.
>
> [...]
Awesome.
It's obvious that assertions for equality are the most common, I
wonder how easy it would be to get other changes merged like
`assert(foo in bar)`. There are also all the assertions that make
use of `equal` because of ranges. In unit-threaded `foo.should ==
bar` works if foo is a range and bar is a dynamic array.
What I'd really like is access to the AST in the assert but alas
I don't think that will ever be possible.
More information about the Digitalmars-d
mailing list