Comment #0 by andrej.mitrovich — 2014-04-25T12:49:18Z
-----
import std.exception;
void main() nothrow
{
// should be marked nothrow
assertThrown!Error( { throw new Error(""); }() );
// ditto
assertNotThrown!Error( { }() );
}
-----
test.d(8): Error: 'std.exception.assertThrown!(Error, void).assertThrown' is not nothrow
test.d(11): Error: 'std.exception.assertNotThrown!(Error, void).assertNotThrown' is not nothrow
test.d(5): Error: function 'D main' is nothrow yet may throw
The way to handle this is to make these two templates wrap function templates inside, and use a static if section to mark one of the code paths as nothrow.
Comment #1 by andrej.mitrovich — 2014-04-25T13:40:57Z
This is invalid since Exception is not derived from Error, so catching Errors will not catch those Exceptions.
Comment #2 by k.hara.pg — 2014-04-25T14:05:58Z
This is a possible enhancement, blocked by issue 12647.
Comment #3 by monarchdodra — 2014-04-25T15:16:13Z
(In reply to Kenji Hara from comment #2)
> This is a possible enhancement, blocked by issue 12647.
12647 was made invalid. assertNotThrown!Error Really has no reason to be nothrow, since it can legally throw exceptions.
Comment #4 by k.hara.pg — 2014-04-25T15:27:35Z
(In reply to monarchdodra from comment #3)
> (In reply to Kenji Hara from comment #2)
> > This is a possible enhancement, blocked by issue 12647.
>
> 12647 was made invalid. assertNotThrown!Error Really has no reason to be
> nothrow, since it can legally throw exceptions.
I agree with that the issue 12646 is invalid, but the newly filed issue 12647 is different thing.
Comment #5 by monarchdodra — 2014-04-25T15:35:52Z
(In reply to Kenji Hara from comment #4)
> (In reply to monarchdodra from comment #3)
> > (In reply to Kenji Hara from comment #2)
> > > This is a possible enhancement, blocked by issue 12647.
> >
> > 12647 was made invalid. assertNotThrown!Error Really has no reason to be
> > nothrow, since it can legally throw exceptions.
>
> I agree with that the issue 12646 is invalid, but the newly filed issue
> 12647 is different thing.
Ah right. I didn't realize the inference was wrong. I thought we were just asking for "always" nothrow.
Comment #6 by robert.schadek — 2024-12-01T16:20:53Z