[Issue 6278] Regression(2.054 beta): 'in' contract inheritance doesn't work with safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 10 04:53:25 PDT 2011


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



--- Comment #6 from yebblies <yebblies at gmail.com> 2011-07-10 21:48:16 EST ---
> Because in general contract violations are errors. There's indeed a special
> case for contracts of overriding functions, but does that justify creating a
> new error type just for that case? I think it's more consistent if all
> contracts throw ContractErrors than if some contracts throw ContractExceptions
> and some other throw AssertErrors.

Only the overridden contracts would throw ContractExceptions, the only way you
would ever see them was if you did:
class A {
  void fun() in { try { assert(0); } catch (ContractException) {} } body {}
}
class B {
  void fun() in {} body {}
}

Which is just horrible.

If we disallow scope(exit/failure) and try/catch inside in contracts assert(x)
could be re-written to if (!x) goto contractfail; which bypasses exceptions
altogether.

-- 
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