Are you looking at the documentation or attempting to compile code? collectException isn't going to be marked as nothrow, because it can only be nothrow if it's collectException!Exception (which _is_ the default), because it can only be nothrow if no Exceptions (be they Exception or derived from Exception) can escape the function - e.g. collectException!MyException can't be nothrow - and neither can stuff like collectException!Error or collectException!AssertError. collectException _should_ be inferred as
nothrow so long as it's collectException!Exception (and
collectException!Throwable should work as well, though I don't know if it
currently does).

If I compile this code on my machine using 2.066.1:

    import std.exception;
    import std.stdio;

    void func()
    {
        throw new Exception("hello");
    }

    void main() nothrow
    {
        auto e = collectException(func());
    }

it compiles just fine. So, it seems like nothrow is being properly inferred for collectException, and I don't know what you're doing that isn't working. Please provide a code snippet that you think should work but doesn't.

- Jonathan M Davis


P.S. In the future, please post questions like this is D.learn. The main newsgroup/mailing list/forum is for discussing the language itself, not for asking questions about how to use it or how it works (or doesn't work).

- Jonathan M Davis

First, sorry about that. I must have glossed over the d.learn forum.

Second, I actually did compile and run it and got the failure. However, reading your response, I'm not wondering if I did make a mistake. In fact, I just tried it again and it did work. Regardless, what you said makes sense. Thanks.

Reply via email to