twrongrefcounting.nim 611 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''ok'''
  3. cmd: "nim c -r --gc:refc -d:useGcAssert -d:useSysAssert -d:fulldebug -d:smokeCycles $file"
  4. """
  5. # bug #9825
  6. func empty(T: typedesc): T = discard
  7. const emptyChunk = @(empty(array[10, byte]))
  8. var lst: seq[seq[byte]]
  9. lst.add emptyChunk
  10. doAssert($lst == "@[@[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]")
  11. # bug #6234
  12. type
  13. Foo = ref object
  14. s: seq[Bar]
  15. Bar = ref object
  16. f: Foo
  17. proc test() =
  18. var f = Foo.new()
  19. for i in 0 .. 5:
  20. f.s = @[]
  21. for j in 0 .. 5:
  22. var b = Bar.new()
  23. b.f = f
  24. f.s.add(b)
  25. test()
  26. echo "ok"