Thread overview
[Issue 7051] New: Class member with un-@safe destructor gives confusing error
Dec 02, 2011
klickverbot
Dec 02, 2011
timon.gehr@gmx.ch
Dec 02, 2011
klickverbot
Dec 02, 2011
timon.gehr@gmx.ch
Jul 02, 2013
David Nadlinger
December 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7051

           Summary: Class member with un-@safe destructor gives confusing
                    error
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@klickverbot.at


--- Comment #0 from klickverbot <code@klickverbot.at> 2011-12-02 09:30:38 PST ---
Consider:
---
struct Foo {
  ~this() {}
}

@safe {
  class Bar {
    Foo f;
  }
}
---

DMD 2.057 Git (887dda0ba) fails with:
---
Error: safe function '~this' cannot call system function '~this'
---

I didn't think about what the best solution for this yet (what exactly is a »safe class« in the first place?), but the error message should certainly be improved.

[related to issue 7050]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7051


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch


--- Comment #1 from timon.gehr@gmx.ch 2011-12-02 09:56:21 PST ---
a @safe class is a class that has only safe members.
This design minimizes the annotation overhead for safe code, because you can
mark every function and method in a module as @safe simply by writing

@safe:

at the top.

The error message should certainly be improved though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7051



--- Comment #2 from klickverbot <code@klickverbot.at> 2011-12-02 09:59:08 PST ---
@Timon: Yes, that's the intuitive meaning of it, but is this actually documented somewhere?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7051



--- Comment #3 from timon.gehr@gmx.ch 2011-12-02 10:11:46 PST ---
Actually I think it is undocumented, but Andrei might have mentioned it in one of his articles iirc. SafeD is generally underspecified.

But I think @safe should certainly transitively apply to members.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7051


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #4 from hsteoh@quickfur.ath.cx 2013-07-02 09:38:17 PDT ---
The error message has improved in git HEAD:

/tmp/test.d(6): Error: safe function 'test.Bar.~this' cannot call system
function 'test.Foo.~this'


Should this issue be resolved?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7051


David Nadlinger <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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