From c75bd8756d148cf3de0b44fd71d4f667da44ef6c Mon Sep 17 00:00:00 2001 From: berni44 Date: Sun, 11 Apr 2021 10:44:19 +0200 Subject: [PATCH] Fix Issue 8424 - Compile time conversions of double/floats to strings --- std/format/internal/write.d | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/std/format/internal/write.d b/std/format/internal/write.d index cac0a1815..e12aa84e3 100644 --- a/std/format/internal/write.d +++ b/std/format/internal/write.d @@ -1033,6 +1033,14 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) assert(format("%#.6g",a) == "-1.00000e+06"); } +// https://issues.dlang.org/show_bug.cgi?id=8424 +@safe pure unittest +{ + static assert(format("%s", 0.6f) == "0.6"); + static assert(format("%s", 0.6) == "0.6"); + static assert(format("%s", 0.6L) == "0.6"); +} + /* Formatting a `creal` is deprecated but still kept around for a while. */