diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index e5f9855..9d53775 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -794,12 +794,16 @@ private: write(" "); break; case tok!"enum": - if (peekBackIs(tok!"identifier")) - write(" "); - indents.push(tok!"enum"); - writeToken(); - if (!currentIs(tok!":")) - write(" "); + if (peekIs(tok!")") || peekIs(tok!"==")) { + writeToken(); + } else { + if (peekBackIs(tok!"identifier")) + write(" "); + indents.push(tok!"enum"); + writeToken(); + if (!currentIs(tok!":")) + write(" "); + } break; default: if (peekBackIs(tok!"identifier")) diff --git a/tests/allman/issue0174.d.ref b/tests/allman/issue0174.d.ref new file mode 100644 index 0000000..1a95194 --- /dev/null +++ b/tests/allman/issue0174.d.ref @@ -0,0 +1,5 @@ +void merge() +{ + static if (is(T == enum)) + *thisN = x; +} diff --git a/tests/issue0174.d b/tests/issue0174.d new file mode 100644 index 0000000..1a95194 --- /dev/null +++ b/tests/issue0174.d @@ -0,0 +1,5 @@ +void merge() +{ + static if (is(T == enum)) + *thisN = x; +} diff --git a/tests/otbs/issue0174.d.ref b/tests/otbs/issue0174.d.ref new file mode 100644 index 0000000..e8df76d --- /dev/null +++ b/tests/otbs/issue0174.d.ref @@ -0,0 +1,4 @@ +void merge() { + static if (is(T == enum)) + *thisN = x; +}