From 2cceaff88abdc2b25d93f34393bfcf4dc6b5ca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Krampe?= Date: Wed, 20 May 2015 11:59:02 +0200 Subject: [PATCH 1/2] Fixes #2749, traverse full inheritance for reprRecord --- lib/system/repr.nim | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/system/repr.nim b/lib/system/repr.nim index f1029ff6a..dbb14bd2c 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -193,11 +193,17 @@ when not defined(useNimRtl): proc reprRecord(result: var string, p: pointer, typ: PNimType, cl: var TReprClosure) = 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 lastPart = "" + while curTyp.base != nil: + var part = "" + reprRecordAux(part, p, curTyp.node, cl) + if part.len > 0: + if lastPart.len > 0: + add result, ",\n" + add result, part + lastPart = part + curTyp = curTyp.base add result, "]" proc reprRef(result: var string, p: pointer, typ: PNimType, From 0fc53151ba00ff31c55798674e21f7e5780320f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Krampe?= Date: Wed, 20 May 2015 12:48:38 +0200 Subject: [PATCH 2/2] Tweaked to do commas properly --- lib/system/repr.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system/repr.nim b/lib/system/repr.nim index dbb14bd2c..be346121a 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -194,15 +194,15 @@ when not defined(useNimRtl): cl: var TReprClosure) = add result, "[" var curTyp = typ - var lastPart = "" + var first = true while curTyp.base != nil: var part = "" reprRecordAux(part, p, curTyp.node, cl) if part.len > 0: - if lastPart.len > 0: + if not first: add result, ",\n" add result, part - lastPart = part + first = false curTyp = curTyp.base add result, "]"