sociomantic-tsunami / ocean

General purpose, platform-dependent, high-performance library for D
Other
61 stars 56 forks source link

Make ocean.core.Test @safe and @nogc, potentially also nothrow #839

Closed AndrejMitrovic closed 3 years ago

AndrejMitrovic commented 3 years ago

Currently we cannot use the test routine within @safe / @nogc unittests:

@safe @nogc unittest
{
    test!"=="(1, 2);  // compile-time error
}

Additionally we cannot use nothrow because test!() throws an Exception rather than an Error.

I do not know of any code which specifically catches exceptions thrown by test!(). I don't see why it couldn't be changed to throw an Error instead.

@safe can be added more easily, there's only a few uses of unsafe features (some exception constructor doesn't have @safe on it, for example).

And finally @nogc could potentially be supported too. If we change test to throw an Error then it should be safe to actually allocate any of the formatted error messages in a static buffer.

AndrejMitrovic commented 3 years ago

I was just informed by Mathias that -checkaction=context already shows the errors when using assert.

So we could close this, unless someone really wants to work on it.

Geod24 commented 3 years ago

Since -checkaction=context now works relatively well, I'm going to close this as WONTFIX.