t4799_3.nim 392 B

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