Assert and the optional Message

Jacob Carlborg doob at me.com
Sat Mar 10 07:52:43 PST 2012


On 2012-03-09 17:56, Jonathan M Davis wrote:

> The current implementation may not skip them, but if so, that might actually
> be a bug. Errors are not intended to be recoverable, so you can't rely on them
> hitting finally blocks, scope statements, or destructors. They may very well do
> so at present. While it's not guaranteed that they will, I'm not sure that
> it's guaranteed that they _won't_. So, it may or may not be a bug if they do.
>
> It was never intended that AssertError or any other Error be particularly
> catchable, but it's also true that D is a systems programming language, so
> it'll let you do stuff which is unsafe, so if you know what you're doing, then
> there are circumstances where you can get away with (unit testing is one
> example of where catching AssertErrors might make sense). But you have to know
> what you're doing, since it's _not_ safe.
>
> - Jonathan M Davis

If it's not safe to catch AssertErrors, how is the executable supposed 
to be able to continue a unit test run when an AssertError has been thrown?

I'm referring to the suggested changes that a unit test run should be 
able to continue in other modules even if an AssertError has been 
thrown. It seems to be issue 5283: 
http://d.puremagic.com/issues/show_bug.cgi?id=5283


-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list