flyx / NimYAML

YAML implementation for Nim
https://nimyaml.org
Other
186 stars 36 forks source link

Unexpected exception: YamlStreamError #90

Closed timotheecour closed 3 years ago

timotheecour commented 3 years ago

example 1

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()
timotheecour commented 3 years ago

see https://github.com/flyx/NimYAML/commit/a72966374fe9c88e0974036131a36a8b4201e20d#r50942534