tcaseobj_transitions.nim 586 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. cmd: '''nim c --newruntime $file'''
  3. output: '''no crash'''
  4. """
  5. # bug #11205
  6. type
  7. MyEnum = enum
  8. A, B, C
  9. MyCaseObject = object
  10. case kind: MyEnum
  11. of A: iseq: seq[int]
  12. of B: fseq: seq[float]
  13. of C: str: string
  14. MyCaseObjectB = object # carefully constructed to use the same enum,
  15. # but a different object type!
  16. case kind: MyEnum
  17. of A, C: x: int
  18. of B: fseq: seq[float]
  19. var x = MyCaseObject(kind: A)
  20. x.iseq.add 1
  21. #x.kind = B
  22. #x.fseq.add -3.0
  23. var y = MyCaseObjectB(kind: A)
  24. y.x = 1
  25. y.kind = C
  26. echo "no crash"