summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-07-26 18:15:19 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2015-07-26 18:15:19 +0100
commitce4e877702d361acd511b14364c26956c06a63d7 (patch)
tree2b8da7335f890421352bc0dbd8bc89e97fb86dd3 /lib/system.nim
parenta88131ed4a660d6eba543a11c2df66c04cdd3908 (diff)
downloadNim-ce4e877702d361acd511b14364c26956c06a63d7.tar.gz
`$` for tuples/objects now handles a nil value correctly. Fixes #3149.
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/system.nim b/lib/system.nim
index c5b0e0cc7..91495f31a 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2173,7 +2173,11 @@ proc `$`*[T: tuple|object](x: T): string =
     if not firstElement: result.add(", ")
     result.add(name)
     result.add(": ")
-    result.add($value)
+    when compiles(value.isNil):
+      if value.isNil: result.add "nil"
+      else: result.add($value)
+    else:
+      result.add($value)
     firstElement = false
   result.add(")")