t18977.nim 350 B

123456789101112131415161718192021222324252627
  1. discard """
  2. matrix: "--mm:arc"
  3. """
  4. type
  5. E = enum
  6. a, b, c, d
  7. X = object
  8. v: int
  9. O = object
  10. case kind: E
  11. of a:
  12. a: int
  13. of {b, c}:
  14. b: float
  15. else:
  16. d: X
  17. proc `=destroy`(x: var X) =
  18. echo "x destroyed"
  19. var o = O(kind: d, d: X(v: 12345))
  20. doAssert o.d.v == 12345
  21. doAssertRaises(FieldDefect):
  22. o.kind = a