tgeneric_smallobj_asgn_opt.nim 512 B

123456789101112131415161718192021222324252627
  1. discard """
  2. output: '''false'''
  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. echo q.contains(123)