What should happen when the assert message expression throws?

Walter Bright newshound2 at digitalmars.com
Fri Nov 18 20:41:54 UTC 2022


On 11/18/2022 4:36 AM, RazvanN wrote:
> I have stumbled upon: https://issues.dlang.org/show_bug.cgi?id=17226

Yes, an interesting problem.

I suggest that have the format() template do the check at compile time, 
analogously to the way printf() formats are statically checked.

The signature of format() is:

   immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args)

so it should be doable as a template constraint.

This would be a good initiative anyway, as it will benefit all uses of format(). 
And if this enables format() itself to be nothrow, even better!

Of course, this does not solve the *general* problem of arguments to assert() 
throwing, but as others suggested, that can be dealt with by:

1. won't fix - too bad, so sad!

2. require such arguments to be nothrow, which is a more robust solution


More information about the Digitalmars-d mailing list