tvariantasgn.nim 388 B

123456789101112131415161718192021222324252627
  1. discard """
  2. output: "came here"
  3. """
  4. #BUG
  5. type
  6. TAnyKind = enum
  7. nkInt,
  8. nkFloat,
  9. nkString
  10. TAny = object
  11. case kind: TAnyKind
  12. of nkInt: intVal: int
  13. of nkFloat: floatVal: float
  14. of nkString: strVal: string
  15. var s: TAny
  16. s = TAny(kind: nkString, strVal: "test")
  17. var nr: TAny
  18. s = TAny(kind: nkInt, intVal: 78)
  19. # s = nr # works
  20. nr = s # fails!
  21. echo "came here"