summary refs log tree commit diff stats
path: root/lib/pure/strformat.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-04-23 10:43:48 +0200
committerAraq <rumpf_a@web.de>2019-04-23 10:44:00 +0200
commit8d206b20d4bd004a18f4ff80d20143c833223a5c (patch)
tree275e9dc73cad9ef6e425485ff49c306344e3ae9a /lib/pure/strformat.nim
parent3161e48760b10a32db17f3ccb89903d6b4555cf1 (diff)
downloadNim-8d206b20d4bd004a18f4ff80d20143c833223a5c.tar.gz
fixes #11089
Diffstat (limited to 'lib/pure/strformat.nim')
-rw-r--r--lib/pure/strformat.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim
index f613a7bb7..89273beb5 100644
--- a/lib/pure/strformat.nim
+++ b/lib/pure/strformat.nim
@@ -432,10 +432,13 @@ proc formatValue*(result: var string; value: SomeInteger; specifier: string) =
       " of 'x', 'X', 'b', 'd', 'o' but got: " & spec.typ)
   result.add formatInt(value, radix, spec)
 
-proc formatValue*(result: var string; value: SomeFloat; specifier: string): void =
+proc formatValue*(result: var string; value: SomeFloat; specifier: string) =
   ## Standard format implementation for ``SomeFloat``. It makes little
   ## sense to call this directly, but it is required to exist
   ## by the ``&`` macro.
+  if specifier.len == 0:
+    result.add $value
+    return
   let spec = parseStandardFormatSpecifier(specifier)
 
   var fmode = ffDefault
@@ -712,6 +715,9 @@ when isMainModule:
   for s in invalidUtf8:
     check &"{s:>5}", repeat(" ", 5-s.len) & s
 
+  # bug #11089
+  let flfoo: float = 1.0
+  check &"{flfoo}", "1.0"
 
   import json