[Issue 3388] New: [tdpl] contracts should allow throw expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 12 13:25:04 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3388

           Summary: [tdpl] contracts should allow throw expressions
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrei at metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei at metalanguage.com> 2009-10-12 13:25:03 PDT ---
Consider:

void fun(int x)
in {
    if (x < 0) throw new Exception("a");
}
body {
}

This doesn't compile with: 

Error: Throw statements cannot be in contracts

This is a useless limitation because a contract could always call a function
that throws an arbitrary exception. So effectively the only effect is that it
makes it difficult for functions to throw custom exceptions when their
contracts are violated. The limitation should be lifted.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list