Add DBUG_ASSERT variations to reduce duplicate code
Many functions start with a bunch of assertions, and rightly so. Making preconditions explicit in dbug_asserts is extremely helpful in stopping the propagation of bugs and conveying the intent to the reader. It is, however, quite repetitive. Consider the following, which I've taken from WLUTupdateBoundNthDim
:
DBUG_ASSERT (bound != NULL, "bound may not be null!");
DBUG_ASSERT (*bound != NULL, "bound may not point to null!");
DBUG_ASSERT (NODE_TYPE (*bound) == N_array || NODE_TYPE (*bound) == N_id,
"bound must be an n_id or n_array but is \"%s\"!",
NODE_TEXT (*bound));
DBUG_ASSERT (new_scalar_avis != NULL, "new_scalar_avis may not be null!");
DBUG_ASSERT (vardecs != NULL, "Vardecs may not be null!");
DBUG_ASSERT (preassigns != NULL, "Preassigns may not be null!");
Frankly, I'm a bit tired of writing the same helpful debug messages over and over again.
Could we instead create some variations of the assertions to weed out most cases?
DBUG_ASSERT_NOT_NULL (bound, *bound, new_scalar_avis, vardecs, preassigns);
DBUG_ASSERT_NODE_IS_OF_TYPES (*bound, N_array, N_id);
This could still expand to give helpful messages as before, just now in an automatic manner.
Are the proposed variants feasible? What variants of DBUG_ASSERT should we make?