diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 74821bf..696b4f8 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -224,7 +224,9 @@ private: else if (currentIs(tok!"return")) { writeToken(); - if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")) + if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{") + && !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do") + && (hasCurrent && tokens[index].text != "body")) write(" "); } else if (currentIs(tok!"with")) diff --git a/tests/allman/issue0521.d.ref b/tests/allman/issue0521.d.ref new file mode 100644 index 0000000..67a0942 --- /dev/null +++ b/tests/allman/issue0521.d.ref @@ -0,0 +1,17 @@ +public int f() return +in (true) +{ + return 0; +} + +public int g() return +out (; true) +{ + return 0; +} + +public int h() return +body +{ + return 0; +} diff --git a/tests/issue0521.d b/tests/issue0521.d new file mode 100644 index 0000000..67a0942 --- /dev/null +++ b/tests/issue0521.d @@ -0,0 +1,17 @@ +public int f() return +in (true) +{ + return 0; +} + +public int g() return +out (; true) +{ + return 0; +} + +public int h() return +body +{ + return 0; +} diff --git a/tests/otbs/issue0521.d.ref b/tests/otbs/issue0521.d.ref new file mode 100644 index 0000000..14f0645 --- /dev/null +++ b/tests/otbs/issue0521.d.ref @@ -0,0 +1,14 @@ +public int f() return +in (true) { + return 0; +} + +public int g() return +out (; true) { + return 0; +} + +public int h() return +body { + return 0; +}