Fix unused warning for $ for empty tuple/objects (#13991)

This commit is contained in:
hlaaftana
2020-04-18 18:41:03 +03:00
committed by GitHub
parent e3919b658f
commit f46803b225

View File

@@ -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