t4799_2.nim 448 B

12345678910111213141516171819202122
  1. discard """
  2. matrix: "--mm:refc"
  3. targets: "c cpp"
  4. outputsub: '''ObjectAssignmentDefect'''
  5. exitcode: "1"
  6. """
  7. type
  8. Vehicle[T] = object of RootObj
  9. tire: T
  10. Car[T] = object of Vehicle[T]
  11. Bike[T] = object of Vehicle[T]
  12. proc testVehicle[T](x: varargs[Vehicle[T]]): string =
  13. result = ""
  14. for c in x:
  15. result.add $c.tire
  16. var v = Vehicle[int](tire: 3)
  17. var c = Car[int](tire: 4)
  18. var b = Bike[int](tire: 2)
  19. echo testVehicle([b, c, v])