diff --git a/src/dfmt.d b/src/dfmt.d index e9cceba..10daade 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -382,6 +382,11 @@ private: case tok!"~": if (peekIs(tok!"this")) { + if (!(index == 0 || peekBackIs(tok!"{") || peekBackIs(tok!"}") + || peekBackIs(tok!";"))) + { + write(" "); + } writeToken(); break; } diff --git a/tests/issue0057.d b/tests/issue0057.d new file mode 100644 index 0000000..30e57bf --- /dev/null +++ b/tests/issue0057.d @@ -0,0 +1,12 @@ + ~this() +{ +} + +extern(C++)~this() +{ global.gag = oldgag; +} + +struct S +{public~this() + { + }} diff --git a/tests/issue0057.d.ref b/tests/issue0057.d.ref new file mode 100644 index 0000000..350b4b6 --- /dev/null +++ b/tests/issue0057.d.ref @@ -0,0 +1,15 @@ +~this() +{ +} + +extern (C++) ~this() +{ + global.gag = oldgag; +} + +struct S +{ + public ~this() + { + } +}