From 4dd05031ec006e2cbf7a835b2c3de5cc78c6557e Mon Sep 17 00:00:00 2001 From: Mathis Beer Date: Fri, 17 Jul 2020 14:14:17 +0200 Subject: [PATCH] Fix issue 497: insert space before function/delegate in function type that returns template instantiated with parenless value argument --- src/dfmt/formatter.d | 4 +++- tests/allman/issue0497.d.ref | 5 +++++ tests/issue0497.d | 5 +++++ tests/otbs/issue0497.d.ref | 5 +++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/allman/issue0497.d.ref create mode 100644 tests/issue0497.d create mode 100644 tests/otbs/issue0497.d.ref diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 6f9b7cc..ae3f798 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -211,7 +211,9 @@ private: { immutable t = tokens[index].type; if (t == tok!"identifier" || isStringLiteral(t) - || isNumberLiteral(t) || t == tok!"characterLiteral") + || isNumberLiteral(t) || t == tok!"characterLiteral" + // a!"b" function() + || t == tok!"function" || t == tok!"delegate") write(" "); } } diff --git a/tests/allman/issue0497.d.ref b/tests/allman/issue0497.d.ref new file mode 100644 index 0000000..eec042e --- /dev/null +++ b/tests/allman/issue0497.d.ref @@ -0,0 +1,5 @@ +alias f1 = S function(); +alias f2 = S!"foo" function(); +alias f3 = S!5 function(); +alias f4 = S!S function(); +alias f5 = S!(S) function(); diff --git a/tests/issue0497.d b/tests/issue0497.d new file mode 100644 index 0000000..eec042e --- /dev/null +++ b/tests/issue0497.d @@ -0,0 +1,5 @@ +alias f1 = S function(); +alias f2 = S!"foo" function(); +alias f3 = S!5 function(); +alias f4 = S!S function(); +alias f5 = S!(S) function(); diff --git a/tests/otbs/issue0497.d.ref b/tests/otbs/issue0497.d.ref new file mode 100644 index 0000000..eec042e --- /dev/null +++ b/tests/otbs/issue0497.d.ref @@ -0,0 +1,5 @@ +alias f1 = S function(); +alias f2 = S!"foo" function(); +alias f3 = S!5 function(); +alias f4 = S!S function(); +alias f5 = S!(S) function();