[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
Wed Feb 1 00:18:48 PST 2012


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


yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|Other                       |All


--- Comment #9 from yebblies <yebblies at gmail.com> 2012-02-01 19:18:47 EST ---
The problem with just letting it catch all throwables in safe code is that it
is _not_ safe, so until we have a better solution I think forcing the user to
mark their function as @trusted is actually correct.

Exceptions thrown in contracts are supposed to be recoverable, which makes
AssertError (or any error) inappropriate.  But if asserts inside contracts are
changed to throw something else, called functions may still throw AssertErrors
that were intended to be caught.

On the other hand, an assert hit inside a contract could easily mean the
program is in an invalid state, and completely break the guarantees of @safe.

I think the best option is to make asserts in contracts throw something else,
despite the downsides.

I understand you would like to undo the regression, but I think re-opening this
hole in @safe is much worse than the current state, especially considering how
trivial the workaround is.

If you know how you would like the solution to look I'm happy to implement it.

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