twrong_rc_for_refarray.nim 398 B

123456789101112131415161718192021222324252627
  1. discard """
  2. output: '''m[0][0] = 1.0
  3. m[0][0] = 2.0'''
  4. """
  5. # bug #4653
  6. type
  7. Vector = ref array[2, float64]
  8. Matrix = ref array[2, Vector]
  9. proc newVector(): Vector =
  10. new(result)
  11. proc newMatrix(): Matrix =
  12. new(result)
  13. for ix in 0 .. 1:
  14. result[ix] = newVector()
  15. let m = newMatrix()
  16. m[0][0] = 1.0
  17. echo "m[0][0] = ", m[0][0]
  18. GC_fullCollect()
  19. m[0][0] = 2.0
  20. echo "m[0][0] = ", m[0][0]