theavy_recursion.nim 759 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. discard """
  2. output: "yay"
  3. cmd: "nim c --gc:arc $file"
  4. """
  5. # bug #15122
  6. import tables
  7. type
  8. BENodeKind* = enum
  9. tkEof,
  10. tkBytes,
  11. tkList,
  12. tkDict
  13. BENode* = object
  14. case kind: BENodeKind
  15. of tkBytes: strVal: string
  16. of tkList: listVal: seq[BENode]
  17. of tkDict: dictVal*: Table[string, BENode]
  18. else:
  19. discard
  20. proc unused(s: string): BENode =
  21. # bad:
  22. result = BENode(kind: tkBytes, strVal: "abc")
  23. proc main =
  24. var data = {
  25. "examples": {
  26. "values": BENode(
  27. kind: tkList,
  28. listVal: @[BENode(kind: tkBytes, strVal: "test")]
  29. )
  30. }.toTable()
  31. }.toTable()
  32. # For ARC listVal is empty for some reason
  33. doAssert data["examples"]["values"].listVal[0].strVal == "test"
  34. main()
  35. echo "yay"