[Issue 17226] Exception during the generation of an assert message hides AssertError

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 19 17:32:59 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=17226

kinke <kinke at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net

--- Comment #8 from kinke <kinke at gmx.net> ---
(In reply to Paul Backus from comment #7)
> Perhaps the simplest way to fix this is to have assert(condition, message)
> evaluate the message *first*

No. Changing the evaluation order would have a deep impact:

* Side effects of evaluating the msg first might change the assert condition's
outcome.
* You don't want a potentially expensive msg expression to be evaluated
unconditionally, i.e., including the regular case where the assertion holds.
* The msg expression may depend on the state after a failed condition - e.g.,
`assert(x.trySomething(), x.getLastErrorMsg())` (horrible, I know...).

--


More information about the Digitalmars-d-bugs mailing list