[Issue 12645] New: assertThrown!Error and assertNotThrown!Error should be nothrow
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Apr 25 05:49:18 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=12645
          Issue ID: 12645
           Summary: assertThrown!Error and assertNotThrown!Error should be
                    nothrow
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: andrej.mitrovich at gmail.com
          Reporter: andrej.mitrovich at gmail.com
-----
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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list