cyclecollector.nim 357 B

123456789101112131415161718192021
  1. # Program to detect bug #1796 reliably
  2. type
  3. Node = ref object
  4. a, b: Node
  5. leaf: string
  6. proc createCycle(leaf: string): Node =
  7. new result
  8. result.a = result
  9. shallowCopy result.leaf, leaf
  10. proc main =
  11. for i in 0 .. 100_000:
  12. var leaf = "this is the leaf. it allocates"
  13. let x = createCycle(leaf)
  14. let y = createCycle(leaf)
  15. main()