tgeneric_smallobj_asgn_opt.nim 576 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. output: "done generic smallobj asgn opt"
  3. """
  4. # bug #5402
  5. import lists
  6. type
  7. Container[T] = ref object
  8. obj: T
  9. ListOfContainers[T] = ref object
  10. list: DoublyLinkedList[Container[T]]
  11. proc contains[T](this: ListOfContainers[T], obj: T): bool =
  12. for item in this.list.items():
  13. if item.obj == obj: return true
  14. return false
  15. proc newListOfContainers[T](): ListOfContainers[T] =
  16. new(result)
  17. result.list = initDoublyLinkedList[Container[T]]()
  18. let q = newListOfContainers[int64]()
  19. if not q.contains(123):
  20. echo "done generic smallobj asgn opt"