Fix infinite recursion when using json.to on ref with cycle.

This commit is contained in:
Dominik Picheta 2017-11-30 18:43:34 +00:00 • committed by Dominik Picheta
commit 2bb2e6975e
3 changed files with 32 additions and 3 deletions

View file

@ -0,0 +1,21 @@
discard """
file: "tjsonmacro_reject2.nim"
line: 10
errormsg: "The `to` macro does not support ref objects with cycles."
"""
import json
type
Misdirection = object
cycle: Cycle
Cycle = ref object
foo: string
cycle: Misdirection
let data = """
{"cycle": null}
"""
let dataParsed = parseJson(data)
let dataDeser = to(dataParsed, Cycle)