tobjconstr2.nim 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. discard """
  2. output: '''42
  3. Foo'''
  4. """
  5. type TFoo{.exportc.} = object
  6. x:int
  7. var s{.exportc.}: seq[TFoo] = @[]
  8. s.add TFoo(x: 42)
  9. echo s[0].x
  10. # bug #563
  11. type
  12. Foo {.inheritable.} =
  13. object
  14. x: int
  15. Bar =
  16. object of Foo
  17. y: int
  18. var a = Bar(y: 100, x: 200) # works
  19. var b = Bar(x: 100, y: 200) # used to fail
  20. # bug 1275
  21. type
  22. Graphic = object of RootObj
  23. case kind: range[0..1]
  24. of 0:
  25. radius: float
  26. of 1:
  27. size: tuple[w, h: float]
  28. var d = Graphic(kind: 1, size: (12.9, 6.9))
  29. # bug #1274
  30. type
  31. K = enum Koo, Kar
  32. Graphic2 = object of RootObj
  33. case kind: K
  34. of Koo:
  35. radius: float
  36. of Kar:
  37. size: tuple[w, h: float]
  38. type NamedGraphic = object of Graphic2
  39. name: string
  40. var ngr = NamedGraphic(kind: Koo, radius: 6.9, name: "Foo")
  41. echo ngr.name
  42. GC_fullCollect()