summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-06-16 20:48:51 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-06-16 20:48:51 +0200
commite2bcf22a849a8093ddb19f97660a519cc8e71371 (patch)
tree0d6fad8cf476aff5c77b03d3fbb16100085fa213 /lib
parentddb62747e88eec3eead7f79e351f7910e197dd44 (diff)
parent0fc53151ba00ff31c55798674e21f7e5780320f0 (diff)
downloadNim-e2bcf22a849a8093ddb19f97660a519cc8e71371.tar.gz
Merge pull request #2768 from gokr/fix-repr
Fixes #2749, traverse full inheritance for reprRecord
Diffstat (limited to 'lib')
-rw-r--r--lib/system/repr.nim16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index efa85b243..37056af3a 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -194,11 +194,17 @@ when not defined(useNimRtl):
   proc reprRecord(result: var string, p: pointer, typ: PNimType,
                   cl: var ReprClosure) =
     add result, "["
-    let oldLen = result.len
-    reprRecordAux(result, p, typ.node, cl)
-    if typ.base != nil: 
-      if oldLen != result.len: add result, ",\n"
-      reprRecordAux(result, p, typ.base.node, cl)
+    var curTyp = typ
+    var first = true
+    while curTyp.base != nil:
+      var part = ""
+      reprRecordAux(part, p, curTyp.node, cl)
+      if part.len > 0:
+        if not first:
+          add result, ",\n"
+        add result, part
+        first = false
+      curTyp = curTyp.base
     add result, "]"
 
   proc reprRef(result: var string, p: pointer, typ: PNimType,