What should happen when the assert message expression throws?

Walter Bright newshound2 at digitalmars.com
Fri Nov 18 22:05:22 UTC 2022


On 11/18/2022 1:33 PM, H. S. Teoh wrote:
> On Fri, Nov 18, 2022 at 12:41:54PM -0800, Walter Bright via Digitalmars-d wrote:
>> 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,
> 
> It already does this. This works:
> 
>          string s = format!"blah %f blah"(123.45);
> 
> and this will produce a compile error:
> 
>          string s = format!"blah %d blah"(123.45);
> 
> So just write:
> 
>          assert(myAssumption, format!"%s doesn't work!"(blah));
> 
> Problem solved.

You should post that to the bug report!



More information about the Digitalmars-d mailing list