diff --git a/src/dfmt.d b/src/dfmt.d index 4337fe9..3c67239 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -317,13 +317,8 @@ private: if (index + 1 < tokens.length) { auto next = tokens[index + 1]; - if (next.type == tok!";" || next.type == tok!"(" - || next.type == tok!")" || next.type == tok!"," - || next.type == tok!"{" || next.type == tok!"." - || next.type == tok!":" || next.type == tok!"*") - { + if (peekIsOperator()) writeToken(); - } else { writeToken(); @@ -848,6 +843,11 @@ private: return peekImplementation(tokenType, 2); } + bool peekIsOperator() + { + return index + 1 < tokens.length && isOperator(tokens[index + 1].type); + } + bool peekIs(IdType tokenType) { return peekImplementation(tokenType, 1); diff --git a/tests/issue0032.d b/tests/issue0032.d new file mode 100644 index 0000000..3877642 --- /dev/null +++ b/tests/issue0032.d @@ -0,0 +1,5 @@ +SignExtendedNumber opSub(const SignExtendedNumber a) const +{ + if (a.isMinimum()) return negative? SignExtendedNumber(value, false) : max(); + else return this+( -a); +} diff --git a/tests/issue0032.d.ref b/tests/issue0032.d.ref new file mode 100644 index 0000000..9a6f97c --- /dev/null +++ b/tests/issue0032.d.ref @@ -0,0 +1,7 @@ +SignExtendedNumber opSub(const SignExtendedNumber a) const +{ + if (a.isMinimum()) + return negative ? SignExtendedNumber(value, false) : max(); + else + return this + (-a); +}