Postmortem: Template unittests are bad & you shouldn't catch Error

Timon Gehr timon.gehr at gmx.ch
Thu Oct 22 16:26:12 UTC 2020


On 22.10.20 18:05, Mathias LANG wrote:
>>
> 
> You disagree with the spec then. The spec says that the stack might not 
> be unwound if an `Error` is thrown. Walter even raised a PR to actually 
> do the optimization the spec promises. In his words:
> 
>> This PR is still the right thing to do. Attempting to unwind when an 
>> Error is thrown is a bad idea, and leads to undefined behavior. 
>> Essentially, code which relies on such unwinding needs to be fixed.
> 
> Source: https://github.com/dlang/dmd/pull/6896#issuecomment-362855793

It's not that simple. The compiler itself catches AssertError when 
checking preconditions.


More information about the Digitalmars-d mailing list