On Friday, 23 December 2016 at 11:21:00 UTC, Atila Neves wrote:
The worst is how useless plain `assert` is.

I would love it, LOVE it, if assert just printed its info.

Consider the following code:

int a = 0;
int b = 1;

assert(a == b);


Wouldn't it just be glorious if that magically printed:

test.d(4): Assertion failure
    (a == b) is false
    a = 0
    b = 1



I'd also settle for it just showing the left hand and right hand side of the comparison.

assert((0 && 1) == b);
prints: `false == 1 failed`

but it would be REALLY nice if it printed the expression then recursed down and found all the various variable things and printed them too.

assert is built in for a reason, I thought, why then is our built in assert crappier than C's library assert?! Let's make it use the compiler's inside info. Let's make it respond accordingly to its environment (so like assert in contracts may be subtly different than in main bodies or unittests etc)

Reply via email to