Bug 3388 – [tdpl] contracts should allow throw expressions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-10-12T13:25:00Z
Last change time
2015-06-09T05:14:46Z
Keywords
patch
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2009-10-12T13:25:03Z
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.
Comment #1 by clugdbug — 2009-10-19T04:13:46Z
This seems to work if you just comment out the error (statement.c 4299) (BTW a nothrow function can have a contract which calls functions that may throw. Not sure if that's OK or not, probably not but I think it's not urgent).
Comment #2 by leandro.lucarella — 2009-11-22T14:34:43Z
Comment #3 by 2korden — 2009-11-24T04:04:42Z
*** Issue 3400 has been marked as a duplicate of this issue. ***
Comment #4 by bugzilla — 2009-12-06T00:52:33Z
Fixed dmd 2.037