Could assertThrown be made safe/trusted?

simendsjo simendsjo at gmail.com
Tue Jan 17 11:26:48 PST 2012


On 17.01.2012 18:07, Jonathan M Davis wrote:
> On Tuesday, January 17, 2012 15:27:04 simendsjo wrote:
>> At the top of the module:
>> @safe:
>>
>> later
>> unittest {
>>     assertThrown(...)
>> }
>>
>> Ooops. AssertThrown not safe.
>>
>> Changing the top to:
>> version(Unittest) {}
>> else { @safe: }
>>
>> makes it work, but then I'll need to use that idom in all safe modules
>> as assert*Thrown is handly methods.
>
> Exception itself isn't @safe yet (its constructor in particular), and I don't
> think that AssertError is either. A number of stuff like that in druntime and
> Phobos still needs to be marked @safe or @trusted.
>
> - Jonathan M Davis

So basically @safe is mostly a no-go as of now? Not sure I understand 
what you mean though.. enforce() can be used in @safe mode.


More information about the Digitalmars-d-learn mailing list