Fix JSON macro bug with ref objects.

This commit is contained in:
Dominik Picheta
2017-04-17 17:59:49 +02:00
parent afb7542d20
commit 2108dcf0d5
2 changed files with 34 additions and 4 deletions

View File

@@ -1608,7 +1608,11 @@ proc createConstructor(typeSym, jsonNode: NimNode): NimNode =
result = processType(typeSym, obj, jsonNode)
of nnkSym:
let obj = getType(typeSym)
result = processType(typeSym, obj, jsonNode)
if obj.kind == nnkBracketExpr:
# When `Sym "Foo"` turns out to be a `ref object`.
result = createConstructor(obj, jsonNode)
else:
result = processType(typeSym, obj, jsonNode)
else:
doAssert false, "Unable to create constructor for: " & $typeSym.kind