when defined case4j:
import yaml
type
Node = ref object
name: string
child: seq[Node]
proc main =
let input = """
{
name: root
child: []
}
"""
let root = loadAs[Node](input)
echo root.name
# static: main()
main()
[NimYAML] Error in file serialization.nim at line 1377:
Unexpected exception: YamlStreamError
[NimYAML] Stacktrace:
Traceback (most recent call last)
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11261.nim(222) t11261
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11261.nim(219) main
/Users/timothee/git_clone/nim/NimYAML/yaml/serialization.nim(1382) loadAs
/Users/timothee/git_clone/nim/NimYAML/yaml/private/internal.nim(20) load
Internal stacktrace:
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11261.nim(222) t11261
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11261.nim(219) main
/Users/timothee/git_clone/nim/NimYAML/yaml/serialization.nim(1382) loadAs
/Users/timothee/git_clone/nim/NimYAML/yaml/serialization.nim(1365) load
/Users/timothee/git_clone/nim/NimYAML/yaml/serialization.nim(1340) construct
/Users/timothee/git_clone/nim/NimYAML/yaml/serialization.nim(1220) constructChild
/Users/timothee/git_clone/nim/NimYAML/yaml/stream.nim(111) peek
/Users/timothee/git_clone/nim/NimYAML/yaml/stream.nim(99) next
/Users/timothee/git_clone/nim/NimYAML/yaml/parser.nim(167) :anonymous
/Users/timothee/git_clone/nim/NimYAML/yaml/parser.nim(483) atBlockIndentationProps
/Users/timothee/git_clone/nim/NimYAML/yaml/stream.nim(104) next
[NimYAML] Please report this bug.
example 2
when defined case4k:
import yaml
type
Node = ref object
name: string
name2: string
proc main =
let input = """
{
name: A
name2: B
}
"""
let root = loadAs[Node](input)
echo root.name
# static: main()
main()
works instead with:
{
name: A,
name2: B
}
example 3
when defined case5b:
import yaml
type
Node = ref object
name1: string
child: seq[Node]
proc main =
let input = """
{
name1: A,
child: [
- name1: B
child: []
]
}
"""
let root = loadAs[Node](input)
echo root.name1
# static: main()
main()
example 1
example 2
works instead with:
example 3