diff --git a/yaml/serialization.nim b/yaml/serialization.nim index eea0f01..f04f607 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -143,7 +143,7 @@ template constructScalarItem*(s: var YamlStream, i: untyped, if i.kind != yamlScalar: raise constructionError(s, "Expected scalar") try: content - except YamlConstructionError: raise + except YamlConstructionError as e: raise e except Exception: var e = constructionError(s, "Cannot construct to " & name(t) & ": " & item.scalarContent & @@ -600,25 +600,40 @@ proc recListNode(n: NimNode): NimNode {.compileTime.} = if n.kind == nnkRecList: result = n[0] else: result = n -proc fieldCount(t: typedesc): int {.compileTime.} = - result = 0 - let tDesc = getType(getType(t)[1]) - if tDesc.kind == nnkBracketExpr: - # tuple - result = tDesc.len - 1 - else: - # object - for child in tDesc[2].children: - inc(result) - if child.kind == nnkRecCase: - for bIndex in 1.. recListIndex: - inc(result, child[bIndex][recListIndex].recListLen) +proc fieldCount(t: NimNode): int {.compiletime.} = + result = 0 + let tDesc = getType(getType(t)[1]) + if tDesc.kind == nnkBracketExpr: + # tuple + result = tDesc.len - 1 + else: + # object + for child in tDesc[2].children: + inc(result) + if child.kind == nnkRecCase: + for bIndex in 1..