t23748.nim 443 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. matrix: "--gc:refc; --gc:arc"
  3. output: '''
  4. hello 42
  5. hello 42
  6. len = 2
  7. '''
  8. """
  9. # bug #23748
  10. type
  11. O = ref object
  12. s: string
  13. cb: seq[proc()]
  14. proc push1(o: O, i: int) =
  15. let o = o
  16. echo o.s, " ", i
  17. o.cb.add(proc() = echo o.s, " ", i)
  18. proc push2(o: O, i: int) =
  19. let o = o
  20. echo o.s, " ", i
  21. proc p() = echo o.s, " ", i
  22. o.cb.add(p)
  23. let o = O(s: "hello", cb: @[])
  24. o.push1(42)
  25. o.push2(42)
  26. echo "len = ", o.cb.len