Sometimes you need to have some extra data to check against in
the assert expression. That data isn't needed in release mode
when assertions are ignored. Therefore, you put that extra data
inside a version(assert). But then those assertions fail to
compile in release mode because the symbol lookup for that extra
data fails. For this reason, assert statements should live inside
version(assert) blocks by default.
Example:
version (assert)
{
const int[1000] maximums = 123;
}
void foo(int value, int index)
{
assert(value < maximums[index]); // [1]
}
void main()
{
foo(11, 22);
}
[1] (In release mode) Error: undefined identifier maximums
...so you need to introduce a redundant version(assert):
void foo(int value, int index)
{
version (assert)
{
assert(value < maximums[index]);
}
}