Bug 3400 – scope(failure) is not allowed in contracts

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-10-14T07:40:00Z
Last change time
2015-06-09T01:28:07Z
Assigned to
nobody
Creator
2korden

Comments

Comment #0 by 2korden — 2009-10-14T07:40:55Z
import std.stdio; int sqrt(int i) out (result) { scope (failure) writeln("ooops"); assert(result * result == i); } body { return i / 2; // buggy implementation :) } Error: Throw statements cannot be in contracts I'm not sure if it's a good idea to disallow throw statements in contracts: It's so easy to overcome this restriction (by calling assert or any other function that will throw) that I don't think it's worth the trouble.
Comment #1 by 2korden — 2009-11-24T04:04:42Z
*** This issue has been marked as a duplicate of issue 3388 ***