summary refs log tree commit diff stats
path: root/lib/system/dollars.nim
diff options
context:
space:
mode:
authorhlaaftana <10591326+hlaaftana@users.noreply.github.com>2020-04-18 18:41:03 +0300
committerGitHub <noreply@github.com>2020-04-18 17:41:03 +0200
commitf46803b225afed53488ef69f84d8775fe8b3fbd3 (patch)
treee51780e956eaade3fce53aef2440433ea328ebec /lib/system/dollars.nim
parente3919b658fb6abaf3b58bbf813bed6f59bd4d1c9 (diff)
downloadNim-f46803b225afed53488ef69f84d8775fe8b3fbd3.tar.gz
Fix unused warning for `$` for empty tuple/objects (#13991)
Diffstat (limited to 'lib/system/dollars.nim')
-rw-r--r--lib/system/dollars.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/system/dollars.nim b/lib/system/dollars.nim
index 664f1c30d..3414c6db1 100644
--- a/lib/system/dollars.nim
+++ b/lib/system/dollars.nim
@@ -75,7 +75,8 @@ proc `$`*[T: tuple|object](x: T): string =
   ##   $(a: 23, b: 45) == "(a: 23, b: 45)"
   ##   $() == "()"
   result = "("
-  var firstElement = true
+  # when x is empty, this gives an unused warning
+  var firstElement {.used.} = true
   const isNamed = T is object or isNamedTuple(T)
   when not isNamed:
     var count = 0