www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17642] New: Specify in the documentation for destructors the

https://issues.dlang.org/show_bug.cgi?id=17642

          Issue ID: 17642
           Summary: Specify in the documentation for destructors the
                    problem with the error InvalidMemoryOperationError
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: crimaniak gmail.com

The current implementation of GC is not re-enterable so users regularly receive
an unexpected InvalidMemoryOperationError. The only reliable way to avoid this
error is not to create garbage-collected instances of objects or structs with
non- nogc destructor. There is no information about it in the documentation,
except error itself description. Nobody reads all possible errors descriptions
before writing code. So then user faced this error usually it's too late to
change architecture and think about ~this()  nogc.

So I propose to add info about this error and how to avoid this to destructors
documentation page 
https://dlang.org/spec/class.html#destructors
or as minimum write a short warning about and give the link to the page with
extended info https://wiki.dlang.org/InvalidMemoryOperationError

--
Jul 12 2017