Comment #0 by moonlightsentinel — 2021-06-15T21:48:43Z
checkaction=context calls user-defined toString-methods if defined. But those can throw an exception which masks the real assertion failure, e.g.:
truct MayThrow
{
int i;
string toString()
{
if (i == 1)
throw new Exception("Error");
return "Some message";
}
}
assert(MayThrow(0) == MayThrow(1));
====================================================
This test will report the exception from toString(), not the assertion failure.
Comment #1 by dlang-bot — 2021-06-15T21:55:01Z
@MoonlightSentinel created dlang/druntime pull request #3499 "Fix 22026 - Catch exceptions thrown by user-defined toString methods... " fixing this issue:
- Fix 22026 - Catch exceptions thrown by user-defined toString methods...
... when formatting values for `-checkaction=context` and print the
aggregate members as a fallback. This ensures that an unrelated error
does not mask the assertion failure.
https://github.com/dlang/druntime/pull/3499