Comment #0 by matti.niemenmaa+dbugzilla — 2007-01-21T06:14:07Z
class Foo { abstract ~this(); }
The above generates "function asdf.Foo._dtor non-virtual functions cannot be abstract". That should read "asdf.Foo.~this".
class Foo { auto ~this(); }
The above is similar: "function asdf.Foo._dtor functions cannot be const or auto". With const the behaviour is, of course, the same.
However, a leftover from before "scope" is the following:
class Foo { scope ~this(); }
This emits "function asdf.Foo._dtor functions cannot be const or auto" as well. This should say something about scope.
Comment #1 by clugdbug — 2009-04-01T09:47:58Z
The 'scope' error has already been fixed for D2, but not for D1.
This simple patch changes __dtor into ~this, by analogy to how it's done for constructors.
Index: declaration.h
===================================================================
--- declaration.h (revision 21)
+++ declaration.h (working copy)
@@ -661,6 +661,8 @@
Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+ const char *kind();
+ char *toChars();
int isVirtual();
int addPreInvariant();
int addPostInvariant();
Index: func.c
===================================================================
--- func.c (revision 21)
+++ func.c (working copy)
@@ -2592,6 +2592,16 @@
return FALSE;
}
+const char *DtorDeclaration::kind()
+{
+ return "destructor";
+}
+
+char *DtorDeclaration::toChars()
+{
+ return (char *)"~this";
+}
+
int DtorDeclaration::isVirtual()
{
/* This should be FALSE so that dtor's don't get put into the vtbl[],