tinheritref.nim 750 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. discard """
  2. output: '''23
  3. 1.5
  4. '''
  5. """
  6. # bug #554, #179
  7. type T[E] =
  8. ref object
  9. elem: E
  10. var ob: T[int]
  11. ob = T[int](elem: 23)
  12. echo ob.elem
  13. type
  14. TTreeIteratorA* = ref object {.inheritable.}
  15. TKeysIteratorA* = ref object of TTreeIteratorA #compiles
  16. TTreeIterator* [T,D] = ref object {.inheritable.}
  17. TKeysIterator* [T,D] = ref object of TTreeIterator[T,D] #this not
  18. var
  19. it: TKeysIterator[int, string] = nil
  20. #bug #5521
  21. type
  22. Texture = enum
  23. Smooth
  24. Coarse
  25. FruitBase = object of RootObj
  26. color: int
  27. case kind: Texture
  28. of Smooth:
  29. skin: float64
  30. of Coarse:
  31. grain: int
  32. Apple = object of FruitBase
  33. width: int
  34. taste: float64
  35. var x = Apple(kind: Smooth, skin: 1.5)
  36. var u = x.skin
  37. echo u