tinheritpartialgeneric.nim 597 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. discard """
  2. output: '''(c: "hello", a: 10, b: 12.0)
  3. (a: 15.5, b: "hello")
  4. (a: 11.75, b: 123)'''
  5. """
  6. # bug #5231
  7. # generic object inheriting from
  8. # partial specialized generic object
  9. type
  10. Curve1[T, X] = object of RootObj
  11. a: T
  12. b: X
  13. Curve2[T] = Curve1[T, float64]
  14. Curve3[T] = object of Curve2[T]
  15. c: string
  16. Curve4[T] = Curve1[float64, T]
  17. Curve5[T] = object of Curve4[T]
  18. Curve6[T] = object of T
  19. var x: Curve3[int]
  20. x.a = 10
  21. x.b = 12.0
  22. x.c = "hello"
  23. echo x
  24. var y: Curve5[string]
  25. y.b = "hello"
  26. y.a = 15.5
  27. echo y
  28. var z: Curve6[Curve4[int]]
  29. z.a = 11.75
  30. z.b = 123
  31. echo z