From ac01da550f85db3f0e77eb40a5a3850578ca21ba Mon Sep 17 00:00:00 2001 From: MetaLang Date: Thu, 23 Jun 2016 22:00:17 -0300 Subject: [PATCH] Fix Issue 12357 - Deprecate calling text, wtext and dtext with 0 arguments --- std/conv.d | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/std/conv.d b/std/conv.d index 4cbeb4c3885..a772cfa08c5 100644 --- a/std/conv.d +++ b/std/conv.d @@ -3672,14 +3672,28 @@ Target parseElement(Target, Source)(ref Source s) /*************************************************************** - * Convenience functions for converting any number and types of - * arguments into _text (the three character widths). + * Convenience functions for converting one or more arguments + * of any type into _text (the three character widths). */ -string text(T...)(T args) { return textImpl!string(args); } +string text(T...)(T args) if (T.length > 0) { return textImpl!string(args); } + +// @@@DEPRECATED_2017-06@@@ +deprecated("Calling `text` with 0 arguments is deprecated") +string text(T...)(T args) if (T.length == 0) { return textImpl!string(args); } + ///ditto -wstring wtext(T...)(T args) { return textImpl!wstring(args); } +wstring wtext(T...)(T args) if (T.length > 0) { return textImpl!wstring(args); } + +// @@@DEPRECATED_2017-06@@@ +deprecated("Calling `wtext` with 0 arguments is deprecated") +wstring wtext(T...)(T args) if (T.length == 0) { return textImpl!wstring(args); } + ///ditto -dstring dtext(T...)(T args) { return textImpl!dstring(args); } +dstring dtext(T...)(T args) if (T.length > 0) { return textImpl!dstring(args); } + +// @@@DEPRECATED_2017-06@@@ +deprecated("Calling `dtext` with 0 arguments is deprecated") +dstring dtext(T...)(T args) if (T.length == 0) { return textImpl!dstring(args); } private S textImpl(S, U...)(U args) { @@ -3695,6 +3709,7 @@ private S textImpl(S, U...)(U args) return result; } } + /// unittest { @@ -3702,12 +3717,6 @@ unittest assert(wtext(42, ' ', 1.5, ": xyz") == "42 1.5: xyz"w); assert(dtext(42, ' ', 1.5, ": xyz") == "42 1.5: xyz"d); } -unittest -{ - assert(text() is null); - assert(wtext() is null); - assert(dtext() is null); -} /***************************************************************