t4799_1.nim 404 B

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