t4799_2.nim 426 B

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