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


Jonathan M Davis <jmdavisp...@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisp...@gmx.com
         Resolution|                            |INVALID


--- Comment #1 from Jonathan M Davis <jmdavisp...@gmx.com> 2012-05-23 14:06:36 
PDT ---
This is not a bug. Per the lanugage, there is no guarantee that finally blocks,
scope statements, or destructors will be run when an Error is thrown, but
neither is there any guarantee that they _won't_ be. So, while relying on them
being executed when an Error is thrown is a bad idea, relying on them _not_
being executed when an Error is thrown is also a bad idea.

The current implementation _does_ always execute finally blocks, scope
statements, and destructors with Errors just like would occur with Exceptions,
and there is quite a lot of debate over whether the language should be changed
to reflect that. Walter is against it, but he's also one of the few who even
realized that the language didn't guarantee that they would be executed for
Errors. Other people who have been working on the exception handling in the
compiler and druntime _did_ think that it was guaranteed, and they wrote that
code with that in mind. In addition, I believe that the spec itself is actually
silent on the matter.

So, the short answer is that you should never rely on scope statements, finally
blocks, or destructors being run or not run when an Error is thrown.

A more thorough discussion of the issues is in this thread on dmd-internals:
http://forum.dlang.org/post/1566418.J7qGkEti3s@lyonel

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

Reply via email to