On Tuesday, 31 May 2022 at 08:51:45 UTC, realhet wrote:
Hi,
In my framework I just found a dozen of compile time error
handling like:
...else static assert("Invalid type");
This compiles without error. And it was useless for detecting
errors because I forgot the first "false" or "0" parameter.
I think it is because of the weird case of "every string casted
to bool is true".
There is an example in Phobos also:
https://github.com/dlang/phobos/blob/master/std/uni/package.d
at line 8847: static assert("Unknown normalization form "~norm);
It is easy to make this mistake, but does static assert(string)
has any meaningful use cases?
I agree that static assert should have a special case for
handling strings, so we have both these signatures:
`static assert(value, message)` and `static assert(message)`