summary refs log tree commit diff stats
path: root/lib/system/repr.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/repr.nim')
-rw-r--r--lib/system/repr.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index 74396f424..b4188527f 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -256,7 +256,10 @@ when not defined(useNimRtl):
     of tyBool: add result, reprBool(cast[ptr bool](p)[])
     of tyChar: add result, reprChar(cast[ptr char](p)[])
     of tyString: reprStrAux(result, cast[ptr string](p)[])
-    of tyCString: reprStrAux(result, $(cast[ptr cstring](p)[]))
+    of tyCString:
+      let cs = cast[ptr cstring](p)[]
+      if cs.isNil: add result, "nil"
+      else: reprStrAux(result, $cs)
     of tyRange: reprAux(result, p, typ.base, cl)
     of tyProc, tyPointer:
       if cast[PPointer](p)[] == nil: add result, "nil"